View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Nov 04, 2019 2:19 am Post subject: Coordinates of mouse click in %gr[full_mouse_input] + %pm |
|
|
I have been experimenting with the option [popup] applied to %gr which allows a %pm menu to appear with %gr[full_mouse_input].
Clearwin_info@('POPUP_X') and clearwin_info@('POPUP_Y') return the coordinates of the right mouse click in the %gr region which initiated the popup menu. These values are screen coordinates and not the position in the %gr region.
Is there an equivalent clearwin_info@ parameter which returns the coordinates of the right mouse click in the graphics region? Or how do I find the position of the origin of the %gr region in screen coordinates?
Thanks
Ken |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon Nov 04, 2019 11:04 am Post subject: |
|
|
Try calling GET_WINDOW_LOCATION@ using the hwnd corresponding to %lc and %gr. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Nov 04, 2019 11:08 am Post subject: |
|
|
What about GRAPHICS_MOUSE_X and _Y ?
Eddie |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Nov 04, 2019 1:19 pm Post subject: |
|
|
Thanks Paul,
That put me on the right track. It was a long day yesterday!
A call to GET_WINDOW_LOCATION@ gives me the screen coordinates of the window (via %hw), say x(0), y(0).
Another call to GET_WINDOW_LOCATION@ gives me the coordinates of the graphics region relative to the window (via %lc), i.e. x(1) and x(1).
Then a call to CLEARWIN_INFO@ ‘POPUP_X’ and ‘POPUP_Y’ gives me the coordinates of the right mouse click relative to the screen; x(2) and y(2).
The coordinates of at which popup click occurred in the graphics region coordinates in local coordinates are then:
X = x(2) – x(0) – x(1)
Y = y(2) – y(0) – y(1)
Eddie,
I could not get GRAPHICS_MOUSE_X and _Y, to work very well – due to the full_mouse_input and the possibility of the user moving the mouse across the sub-menus in the popup or outside the popup. I also had a %^gr call back in there at one point along side the %pm – all very confusing,
Ken |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Nov 04, 2019 2:18 pm Post subject: |
|
|
Probably the full_mouse_input catches you out, agreed. My biggest app works without proper Clearwin+ popups as they didn't work when I was developing it, and I had to make my own using volatile and drop_shadow windows. The big advantage, I found later, with a do-it-yourself approach is that the pop ups can contain data input boxes, e.g. if the first pop up contains 'edit coordinates', that can launch another that has boxes in which to edit them.
You probably had to go to full-mouse_input because with the quick and dirty method the left click has to be assigned to something unimportant because you get one before and after a double-click.
So GRAPHICS_MOUSE_X etc works for me.
Eddie |
|
Back to top |
|
|
|