[Fxruby-users] Re: Elementary FXDialogBox query
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <ly...@kn...> - 2004-06-06 21:52:13
|
On Jun 6, 2004, at 6:47 AM, Nigel Wilkinson wrote: > Thanks, I've now got it working. Out of curiosity what class does > theDialog.textField return as I have had to use > theDialog.textField.to_s to use it as a string. When you define an attr_accessor for a Ruby class, e.g. class MyClass attr_accessor :foo end it creates a new instance method named "foo" that will allow clients to get or set the value of that instance variable, e.g. anObject = MyClass.new anObject.foo = Bar.new x = anObject.foo So for the dialog box class from your previous example, we had an attr_accessor named "textField", and in the class' initialize method we assigned an FXTextField object to it: @textField = FXTextField.new(...) So when you call: anAddItemDialog.textField it returns a reference to the FXTextField object. To find out about what methods you can call on an FXTextField (or any other FXRuby class), you can consult the on-line documentation at http://www.fxruby.org. For example, here's a direct link to the FXTextField class docs: http://www.fxruby.org/doc/api/classes/Fox/FXTextField.html As shown in the "Attributes" section, the "text" method returns a String containing the FXTextField's text. Because FXTextField is so smart, it also does this when you call the text field's to_s() method. ;) Hope this helps, Lyle |