[fxruby-users] Retriving FXTextField Data

Lyle Johnson lyle at knology.net
Tue Mar 29 07:19:25 EST 2005


On Mar 28, 2005, at 10:59 PM, Harold Worby wrote:

> Now I added the '.connect(SEL_COMMAND){' and the data is correct, but 
> the
> Accept button does not dimiss the diallog 'dlg'.
> As I read the docs, FXButton.new(parent, text, icon, target, selector,
> opts,...),
> should be creating a button that will send the message 
> 'selecotor'(ID_ACCEPT
> hear) to the object 'target'(dlg here).

Yes...

> Which is what it seemed to do before I added the .connect(SEL_COMMAND)
> {block}
> I expect it catch the SEL_COMMAND message, execute the {block} and 
> then send
> the ID_ACCEPT message. Why doesn't it?

As soon as you call connect() on the button, it replaces the previously 
designated message target (the dialog box) with a new one -- an 
"anonymous" target, if you like, that responds to the SEL_COMMAND 
message from the button. And FOX only allows one message target object 
per widget, so in this case it's the latter object (the anonymous one) 
that wins.

To accomplish what you want, I'd just write it this way:

	FXButton.new(buttons, "&Accept", nil, nil, 0, 
...).connect(SEL_COMMAND) {
		@table.setItemText(cell.row,1,txtName.text)
		@table.setItemText(cell.row,2,txtPath.text)
		@table.setItemText(cell.row,3,txtSize.text)
		getApp().stopModal(dlg, true)
		dlg.hide
	}

or more directly:

	FXButton.new(buttons, "&Accept", nil, nil, 0, 
...).connect(SEL_COMMAND) {
		@table.setItemText(cell.row,1,txtName.text)
		@table.setItemText(cell.row,2,txtPath.text)
		@table.setItemText(cell.row,3,txtSize.text)
		dlg.handle(self, FXSEL(SEL_COMMAND, FXDialogBox::ID_ACCEPT), nil)
	}

Hope this helps,

Lyle



More information about the fxruby-users mailing list