fineberg@ANTARES.MCS.ANL.GOV (08/02/89)
I am writting an application using Widgets and I want to have a popup widget appear where the cursor is or else, at least where a known widget is. When I get the x and y back from the event handler it is relative to the widget I clicked on (0,0 is the upper left corner of the widget). Also, when I try to get x and y values for the position of the widget it is relative to my toplevel widget and when I get x and y for my toplevel widget they are 0 and 0. If I could get the x and y of the toplevel widget this would be sufficient, hoever, what I really want is the cursor position when the event occurred. Thanks, Sam Fineberg
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (08/03/89)
> When I get the x and y back from the event handler it is relative to > the widget I clicked on ... what I really want is the cursor > position when the event occurred. Thanks, Use XtTranslateCoords(). Note: there is a small bug in this routine in R3 that causes the toolkit not to track movements of the window once it has been initially placed. If you are planning to distribute your code before R4 is avaliable then you might want to temporarily use XTranslateCoordinates(). Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213
pusateri@romeo.cs.duke.edu (Thomas J. Pusateri) (08/03/89)
In article <8908021500.AA01836@godzilla.mcs.anl.gov>, fineberg@ANTARES.MCS.ANL.GOV writes: > I am writting an application using Widgets and I want to have a popup > widget appear where the cursor is or else, at least where a known widget > > Sam Fineberg Sam, Haven't talked to you in a while. (If your the same Sam Fineberg I worked with at Purdue!) Anyway, here is a code fragment taken from a pop up menu widget that puts the popup where you want it. Tom Pusateri National Biomedical Simulation Resource Duke University Medical Center pusateri@nbsr.mc.duke.edu ---------------------------------------------------------------------------- * MenuShell Widget * Robert Blumen blumen@arisia.xerox.com blumen@cad.berkeley.edu * /*********************************************************** Copyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that /*----------------------------------------------------------- Find out where the pointer is and put the menu there. Geometry request should always be satisfied since we are an override shell. */ static void _GetLocation(w) Widget w; { MenuShellWidget msw = (MenuShellWidget) w; Window root, child; int x_root, y_root, x_win, y_win; unsigned int mask; XtWidgetGeometry request; XQueryPointer( XtDisplay( msw ), XtWindow( msw ), &root, &child, &x_root, &y_root, &x_win, &y_win, &mask); request.request_mode = CWX | CWY; switch (msw->menu.menu_under_cursor) { case XtJustifyLeft: request.x = x_root; break; case XtJustifyCenter: request.x = x_root - msw->core.width/2; break; case XtJustifyRight: request.x = x_root - msw->core.width; break; default: XtError("wrong type of menu justify.\n"); break; } request.y = y_root -1; XtMakeGeometryRequest(msw, &request, (XtWidgetGeometry *)NULL); return; }