1. Home
  2. Computing & Technology
  3. Ruby

How Can Shoes Have Buttons?

By Amanda & Michael Morin, About.com

3 of 4

Appending Elements

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.

Explore Ruby
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Ruby
  4. GUI
  5. Shoes
  6. Appending Elements

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

All rights reserved.