1. Computing
Send to a Friend via Email

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.

©2014 About.com. All rights reserved.