1. Home
  2. Computing & Technology
  3. Ruby

Click Blocks and Animation

By Amanda & Michael Morin, About.com

1 of 5

Click Blocks

Elements in Shoes applications can respond to a number of events, the most common of which is the click event. Any element can be assigned a "click block," a block of code to run when the element is clicked. If the element is clicked, the click block will run. This can make any element--including text, images, or an entire stack or flow itself--behave somewhat like a button.

The following example assigns a click block using the click method. The click method assigns a click block to the entire enclosing element which, in a stack or a flow, would be the stack or flow itself. Alone, it will simply assign the click block to the entire application.

Shoes.app :width => 300, :height => 200 do
  @box = stack

  click do
    @box.append para("You clicked the window\n")
  end
end
Explore Ruby
About.com Special Features

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

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Ruby
  4. GUI
  5. Shoes
  6. Click Blocks and Animation

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

All rights reserved.