[fxruby-users] dialog.execute vs dialog.show

Lyle Johnson lyle at knology.net
Mon Mar 21 20:13:28 EST 2005

On Mar 21, 2005, at 10:04 AM, Harold Worby wrote:

> How would one create FXEvent object that references a widgets events? I
> mean in:
>     tree= FXTreeList.new(@group1, 0, nil, 0,...)
>     tree.connect(SEL_CLICKED  ) do |sender, selector, ptr|
>         y=myFXEvent.win_y
>         itemselect(sender, selector, ptr,y)
>       end
> How would you declare the myFXEvent object. As part is the application,
> the widget, or in the event routine?

You don't actually create an FXEvent object yourself; FOX creates one 
and passes it into some message handler routines as the event data.

Now in general, you can find out what kind of message data is passed in 
as the message data for a message handler block by looking at the API 
documentation for the class that sends the message. In this case, it's 
an FXTreeList who sends the message (a SEL_CLICKED message), so you 
look at the docs for FXTreeList:


and in the list of events near the top of that page, you will see that 
the message data for SEL_CLICKED is a reference to the FXTreeItem that 
was "clicked". So something like this should do the trick:

	tree.connect(SEL_CLICKED) do | sender, sel, clickedItem |

Now this doesn't tell you anything about the (x, y) position that was 
clicked, but let's read on...

> The idea is when the user to clicks on a leaf item a read only text box
> appears over the top of it displaying more detailed information about
> the item. Then when the user clicks again the text box goes away.
> I.E.
>     dlg =
> FXDialogBox.new(@group1,"FileInfo",DECOR_BORDER,x,y,w,h,2,2,2,2,0,0)
>     textbox=FXTextField.new(dlg, 200,
> dlg,FXDialogBox::ID_CANCEL,TEXTFIELD_READONLY,2,2,w-4,h-4,0,0,0,0)
>     textbox.text=item.data.to_s

OK, so for starters I would recommend calling dlg.execute without any 


or explicitly specifying the placement, if you like:


so that the dialog box will appear on top of the tree item that the 
user just clicked. In that case, you don't actually need to know the 
(x, y) coordinates. Also, if it's a read-only field anyways, I might 
consider using an FXLabel instead of an FXTextField, since an 
FXTextField suggests to the user that this is a field they can edit and 
change. Finally, I think I'd add a "Close" button -- even a small one 
-- to the dialog box to allow the user to dismiss it. And if that's the 
case, that you're basically looking for a dialog box with an OK button 
and some text label, you might instead consider the FXMessageBox class, 
a subclass of FXDialogBox that is intended exactly for that purpose.

> P.S.
> I now have updated to v1.5.

I hate to ask (because I think I know the answer), but you've updated 
*what* to version 1.5? ;)

> Thanks for the help.

No problem!

More information about the fxruby-users mailing list