1. Home
  2. Computing & Technology
  3. Ruby

How Can Shoes Have Buttons?

By , About.com Guide

1 of 4

A Basic Button

The button is one of the simplest elements your Shoes applications in Ruby. After all, isn't a button just a simple element anyway? It has text and it does something when you click on it. It's just that simple. The button is one of the most used elements in Shoes applications.

The button method takes a single argument: the text to display in the button. Optionally, the button can also takes a block to define what happens when you click on the button.(Of course, a button that doesn't do anything isn't particularly useful).

The following example creates a button that displays an alert when you click on it. The alert method is a lot like the alert method in Javascript or the MessageBox function on Windows. It will display a popup dialog box with your message and an OK button.

Shoes.app :width => 200, :height => 140 do
  button "Press me" do
    alert "You pressed me"
  end
end
Explore Ruby
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Ruby
  4. GUI
  5. Shoes
  6. How Can Shoes Have Buttons?

©2009 About.com, a part of The New York Times Company.

All rights reserved.