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 = '' end end end
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.