I would like to retrieve the GadgetID of the gadget where I use Right Mouse Button or where I drag an external object on it. Is it possible ?
For now, it works for me in Left mouse button release.
- case WMHI_GADGETUP:
- if ( ((result & WMHI_GADGETMASK) - LAST_NUM) < nb_program)
- printf("GadgetID = %d \n",(result & WMHI_GADGETMASK) - LAST_NUM) ;
but no in "case WMHI_MOUSEBUTTONS:" or in WINDOW_AppMsgHook hook.
For these 2 cases, I have to calculate the coordinate of the targeted object with Window->MouseX or msg->am_MouseX and to determine the gadgetID on my window by calculating the width of the existing gadgets... Not very nice.
Is it a easier solution ?
Thank you by advance
Hi, can you elaborate it a bit further please?
You want that when user clicks RMB over some gadget to act/show something?
Why not with LMB?
Thanks for your reply.
yes, i want that when I RMB on a gadget or when I drag an element on a gadget to be able to retrieve the gadget ID of this gadget.
It works well by using LMB thanks to (results & WMHI_GADGETMASK) but not when with right mouse button or drag'n drop (appmsghook)
For drag and drop I think the only way is to take the coordinates of the from the appmessage and compare them with your gadgets. You *might* be able to send a GM_HITTEST to each gadget you are interested in, I say *might* because I'm not sure if it's legal for an application to send this message or onlt intuition.
For captureing RMB events it's more complex, as by default button.gadgets do not monitor the RMB, so you might need to create a subclass, even then the gadget wil not recive input till active so you may need to monitor the mouse position and activate the gadgets hovered over via WM_ACTIVATEGADGET
However be aware that this will messup menu access so you will be to process the RMB click appropriatly, basically you need to do some studying of the gadgets section of the RKMs (on the wiki.amigaos.net)and the gadget_gc autodoc
*But* if you are intended to bring up a popup menu then you might take look at the new menuclass (not sure if you have access to latest SDK or not)
Maybe it's sort of a hack but you can use this code to check on RMB click and then perform/call/simulate a LMB click.
Or use popupmenu/new_menu class as broadblues suggested if you want to show just a contextmenu under gadgets.
Thank you Broadblues and Jabirulo,
therefore no easy way to retrieve the gadget ID in these cases.
I still calculate the targeted gadget by calculating the position with MouseX and am_MouseX. It works well, I wondered if there is not an easier way. At least it works !