1. Computing

How Can Shoes Have Buttons?

By , About.com Guide

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. Computing
  3. Ruby
  4. Graphical User Interfaces
  5. Shoes
  6. Appending Elements

©2013 About.com. All rights reserved.