1. Computing

Click Blocks and Animation

By

1 of 5

Click Blocks
Click Blocks and Animation

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
  1. About.com
  2. Computing
  3. Ruby
  4. Graphical User Interfaces
  5. Shoes
  6. Click Blocks and Animation

©2014 About.com. All rights reserved.