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

Edit Boxes


1 of 3

Basic Usage
Edit Boxes

In our article about displaying text and paragraphs in Shoes, we discussed how the World Wide Web and HTML heavily influenced the GUI. In keeping with Shoes' parallel to HTML, there are two primary ways of displaying an edit box. The first method is the single line edit box, which is created by the edit_line method. The object returned by this method (usually stored in an instance variable) can be used to read the text in the edit box at any time.

Shoes.app :width => 400, :height => 340 do
  flow do
    @e = edit_line
    button "Go!" do
      alert @e.text
      @e.text = ''

You'll noticed that in the above example, the edit_line object is stored in the instance variable @e. When the button is pressed, the alert method is passed the text from @e. After the alert method is finished, the text is set to the empty string, essentially clearing the edit_line.

  1. About.com
  2. Technology
  3. Ruby
  4. Graphical User Interfaces
  5. Shoes
  6. Edit Boxes

©2014 About.com. All rights reserved.