Hi
I'm trying to use a dialog box in FXRuby.
I have a class set up as follows
class AddItemDialog < FXDialogBox
def initialize(owner)
super(owner, "Add entry dialog")
FXLabel.new(self, "Entry Name")
textField = FXTextField.new(self, 20)
buttons = FXHorizontalFrame.new(self, LAYOUT_SIDE_BOTTOM|FRAME_NONE|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
FXButton.new(buttons, "&Accept", nil, self, ID_ACCEPT, FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
end
def create
super
show
end
end
When invoked I get the dialog that closes when either of the buttons is pressed and returne a 1 or a 0 depending on which button is pressed.
What I want to do is capture the text in the text field so i tried
class AddItemDialog < FXDialogBox
def initialize(owner)
super(owner, "Add entry dialog")
FXLabel.new(self, "Entry Name")
textField = FXTextField.new(self, 20)
buttons = FXHorizontalFrame.new(self, LAYOUT_SIDE_BOTTOM|FRAME_NONE|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH)
FXButton.new(buttons, "&Accept", nil, self, ID_ACCEPT, FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
FXButton.new(buttons, "&Cancel", nil, self, ID_CANCEL, FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
if self.execute != 0
puts textField.text
end
end
def create
super
show
end
end
Now if the accept button is pressed it returns the text field entry but the dialog box stays visable, if the accept button is pressed again the dialog disappears and it returns 1.
Any pointers would be gratefully received.
Cheers
Nigel