1. Computing
Send to a Friend via Email

Edit Boxes

By

3 of 3

Multi-line edit_box
Edit Boxes

An edit_box works exactly the same as an edit_line, with one slight difference. An edit_box allows you to edit multiple lines, whereas an edit_line only allows you to edit a single line. Using only an edit_line, edit_box and two buttons, you can make a crude text editor.

Shoes.app :width => 400, :height => 300 do
  flow do
    @e = edit_line :width => -50
    button "Load", :width => 50 do
      @box.text = File.read( @e.text )
    end
  end
  stack do
    @box = edit_box :width => '100%', :height => 230
    button "Save", :width => '100%' do
      File.open( @e.text, 'w+' ) do|f|
        f.write @box.text
      end
    end
  end
end
 

©2014 About.com. All rights reserved.