Silverfrost Forums

Welcome to our forums

Coordinates of mouse click in %gr[full_mouse_input] + %pm

4 Nov 2019 1:19 #24622

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

4 Nov 2019 10:04 #24623

Try calling GET_WINDOW_LOCATION@ using the hwnd corresponding to %lc and %gr.

4 Nov 2019 10:08 #24624

What about GRAPHICS_MOUSE_X and _Y ?

Eddie

4 Nov 2019 12:19 #24625

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

4 Nov 2019 1:18 #24626

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

Please login to reply.