1. Computing
Send to a Friend via Email

How Can Shoes Have Buttons?

By

2 of 4

Changing Text With a Button
How Can Shoes Have Buttons?

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
  1. About.com
  2. Computing
  3. Ruby
  4. Graphical User Interfaces
  5. Shoes
  6. Changing Text With a Button

©2014 About.com. All rights reserved.