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

Lyle Johnson lyle at knology.net
Mon Mar 21 09:18:13 EST 2005

On Mar 20, 2005, at 8:58 PM, Harold Worby wrote:

> Any idea why using dlg.execute vs. dlg.show would place the TextField 
> at a
> radically different screen position?
> dlg.show does as I would expect, placing the field at the top of the 
> main
> window.
> dlg.execute places the field over the tree where I but the x 
> coordinate is
> way to the left.
> I have no idea where dlg.execute is picking up the y coordinate.

The FXDialogBox#execute method takes an optional argument that allows 
you to specify the placement of the dialog box on the screen:


As shown in the documentation, the default value for that placement 
argument is PLACEMENT_CURSOR, which means "place this dialog box under 
the current cursor position", which is usually a pretty good place to 
put it. In your case, I think you're saying that you want to fix the 
initial x & y coordinates of the dialog box, so you might instead 
choose to use the PLACEMENT_DEFAULT option:


Now, the show() method that you're also trying is inherited from the 
FXWindow class:


and it takes no arguments, and its behavior is like PLACEMENT_DEFAULT. 
For completeness, there's also a different version of show (defined in 
FXTopWindow) that does take one argument for the 'placement'.

> Also:
> How can I determine the width of the FXVerticalFrame the FXTreeList is 
> being
> displayed in?

Unless I'm misunderstanding the question, just call its width method:

	theWidth = someVerticalFrame.width

> How can I pickup the screen position of a FXTreeListItem?

Well, I don't think we have a way to do that, exactly. There's a 
getItemAt method, which will return a reference to the tree item at 
some (x, y) position (if any), e.g.

	theItemAtXY = treeList.getItemAt(x, y)

but I don't know of any easy way to get the (x, y) position of an item.

> I tried to use FXEvent.win_y in the trees event code to get the 
> coordinate
> of the event (close enough) but get a runtime error:
> 'undefined method `win_y' for Fox::FXEvent:Class (NoMethodError)'

FXEvent#win_y is an instance method, not a class method. That is, you 
need to have an FXEvent object lying around and call its win_y() method 
to get the y-coordinate.

> Lastly in this code I try to set the FXTextField target to be it's 
> parent
> dialog window and send a FXDialogBox::ID_CANCEL when it is ckicked to 
> close
> the dialog. Why doesn't this work?

I don't think I understand this at all. You're creating a dialog box 
that contains a text field (which is used to allow the user to enter 
and edit a line of text), but you want the dialog box to close as soon 
as the user clicks inside that text field?

More information about the fxruby-users mailing list