[fxruby-users] Retriving FXTextField Data

Harold Worby haroldworby at earthlink.net
Sat Apr 2 21:16:14 EST 2005


Ok, here's the complete function.
The paramater passed as (cell) is handle to a FXTableItem.
The calling line is
	dlgNewTest(cell)
When then button.connect uses:
		getApp().stopModal(dlg, true)
		dlg.hide
I get:
table.rbw:224:in `stopModal': No matching function for overloaded
'FXApp_stopModal' (ArgumentError)
And when I use:
		 dlg.handle(self, FXSEL(SEL_COMMAND, FXDialogBox::ID_ACCEPT), nil)
I Get:
table.rbw:227:in `dlgNewTest': undefined method `FXSEL' for
#<TableWindow:0x32955f8>
NoMethodError)

I'm guessing the the issue has to to do with the scope of the dlg object?

What overloaded 'FXApp_stopModal'?


#####################################################
def dlgNewTest(cell)
    dlg = FXDialogBox.new(getApp(),"Edit
Destination",DECOR_TITLE|DECOR_BORDER,0,0,0,0)
    outter = FXVerticalFrame.new(dlg,LAYOUT_FILL_X|LAYOUT_FILL_Y)
    # Contents
    inner =  FXHorizontalFrame.new(outter,LAYOUT_FILL_X|LAYOUT_FILL_Y)
    labels  = FXVerticalFrame.new(inner,LAYOUT_FILL_X|LAYOUT_FILL_Y)
	    lblName=FXLabel.new(labels,"Name",nil,LABEL_NORMAL)
	    lblPath=FXLabel.new(labels,"Pathname",nil,LABEL_NORMAL)
	    lblSize=FXLabel.new(labels,"Size Limit",nil,LABEL_NORMAL)
    fields  = FXVerticalFrame.new(inner,LAYOUT_FILL_X|LAYOUT_FILL_Y)
         txtName=FXTextField.new(fields ,20 , nil,TEXTFIELD_NORMAL)
	 txtName.text=@table.getItemText(cell.row,1)
         txtPath=FXTextField.new(fields ,66 , nil,TEXTFIELD_NORMAL)
	 txtPath.text=@table.getItemText(cell.row,2)
         txtSize=FXTextField.new(fields ,12 , nil,TEXTFIELD_NORMAL)
	 txtSize.text=@table.getItemText(cell.row,3)
    # Separator
    FXHorizontalSeparator.new(outter,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|SEPARA
TOR_GROOVE)
    # Bottom buttons
    buttons=FXHorizontalFrame.new(outter)
  	 # Accept
	btnAccept=FXButton.new(buttons, "&Accept", nil, nil, 0,
	  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
	btnAccept.connect(SEL_COMMAND){|sender, selector, data|
		 @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
#gives table.rbw:224:in `stopModal': No matching function for overloaded
'FXApp_stopModal' (ArgumentError)
		 dlg.handle(self, FXSEL(SEL_COMMAND, FXDialogBox::ID_ACCEPT), nil)
#gives table.rbw:227:in `dlgNewTest': undefined method `FXSEL' for
#<TableWindow:0x32955f8> (NoMethodError)

	    }
	# Cancel
	btnCancel=FXButton.new(buttons, "&Cancel", nil, dlg,
FXDialogBox::ID_CANCEL,
	  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
	btnCancel.connect(SEL_COMMAND){|sender, selector, data|
	    }
	# Delete
	btnDelete=FXButton.new(buttons, "&Delete", nil, dlg,
FXDialogBox::ID_CANCEL,
	  FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
	btnDelete.connect(SEL_COMMAND){|sender, selector, data|
		 sql="DELETE FROM DESTINATIONS WHERE "
		 sql=sql + " name='" + txtName.text + "'"
		 sql=sql + " and pathname='" + txtPath.text + "'"
	    }
    dlg.create
    dlg.execute
end
#####################################################
> -----Original Message-----
> From: fxruby-users-bounces at rubyforge.org
> [mailto:fxruby-users-bounces at rubyforge.org]On Behalf Of Lyle Johnson
> Sent: Tuesday, March 29, 2005 6:19 AM
> To: Harold Worby
> Cc: fxruby-users at rubyforge.org
> Subject: Re: [fxruby-users] Retriving FXTextField Data
>
>
>
> 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
>
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users
>




More information about the fxruby-users mailing list