1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

How Can Shoes Have Buttons?

By

3 of 4

Appending Elements
How Can Shoes Have Buttons?

Elements can be appended to stacks and flows without altering the other elements already present. The append method does this, and it takes a block defining the elements to append.

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

  stack do
    button "Press me" do
      @times += 1
      @p.append { para "You pressed me #{@times} t imes" }
    end

    @p = flow
  end
end

Similarly, the prepend method can be used to add elements to the beginning of the stack or flow.

  1. About.com
  2. Technology
  3. Ruby
  4. Graphical User Interfaces
  5. Shoes
  6. Appending Elements

©2014 About.com. All rights reserved.