1. Home
  2. Computing & Technology
  3. Ruby

How Can Shoes Have Buttons?

By , About.com Guide

2 of 4

Changing Text With a Button

Each stack or flow can be edited at runtime, meaning that elements can be appended to or removed from them at will. The most basic way to do this is by using the clear method. Calling clear on any stack or flow removes all the elements from it. You also have the option to pass clear a block that defines a number of new elements to go inside of it. This can be used as a quick way to clear and replace the elements of a stack or flow.

Shoes.app :width => 200, :height => 140 do
  @times = 0

  stack do
    button "Press me" do
      @times += 1
      @p.clear { para "You pressed me #{@times} ti mes" }
    end

    @p = flow
  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. Changing Text With a Button

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

All rights reserved.