How to know MouseX/MouseY when RMB is pressed without to use RMB_Trap ?

7 posts / 0 new
Last post
zzd10h
zzd10h's picture
Offline
Last seen: 6 years 11 months ago
Joined: 2012-08-24 20:56
How to know MouseX/MouseY when RMB is pressed without to use RMB_Trap ?

Hi,
Again me with another question about Reaction/Intuition.

Sorry for all these newby questions... It's my first Reaction project...

In my program i have to catch MouseX/MouseY where the user hit the RMB.

I do that without problem in WMHI_MOUSEBUTTONS / MENUDOWN. I can even use a popupmenu.
I only have to add WINDOW_GadgetHelp,TRUE and WA_RMBTrap, TRUE to my window.

It works, it's perfect !

Now, I try to replace my PopupMenu by a NewMenu to be able to add menu entry to the Workbench TitleBar BUT I have to remove WA_RMBTrap otherwise the NewMenu doesn't work at all.

By removing WA_RMBTrap and by using NewMenu, WMHI_MOUSEBUTTON doesn't work anymore. And unfortunately WMHI_MENUPICK seems to retrieve only the mouse coordinates AFTER RMB release.

Is somebody know how to :

1) to detect MouseX/MouseY when RMB is pressed when using NewMenu ?

OR

2) a way to add menus entries to the WB TitleBar when using PopupMenu ?

Here is the SDK sample where I tried to show the problem.

By uncommenting

  1. WINDOW_GadgetHelp,TRUE,
  2. WA_RMBTrap, TRUE,

and by commenting

  1. //WA_NewLookMenus, TRUE,
  2. //WINDOW_NewMenu, mynewmenu,

the RMB coordinates will be retrieved as soon as RMB is pressed (print of "MENUDOWN MouseX") but NewMenu will not work

By commenting

  1. // WINDOW_GadgetHelp,TRUE, // zzd10h
  2. // WA_RMBTrap, TRUE, // zzd10h

and by uncommenting

  1. WA_NewLookMenus, TRUE,
  2. WINDOW_NewMenu, mynewmenu,

the RMB coordinates will be retrieved only after RMB is released (print of "MENUPICK MouseX") but NewMenu will work

http://zzd10h.amiga-ng.org/Divers/Menu_Intuition.lha

Thank you by advance for your help
Guillaume

thomas
thomas's picture
Offline
Last seen: 2 months 8 hours ago
Joined: 2011-05-16 14:23
You can have only one. With

You can have only one. With RMBTRAP set you disable the menu strip but receive MOUSEBUTTON events for the right mouse button. With RMBTRAP clear you enable the menu strip but will never hear about right mouse clicks.

Now I have difficulties to understand your problem. You say you want mouse coordinates in conjunction with a menu strip. Why? If the menu strip opens, you never receive control, so why do you need mouse coordinates?

One behaviour one could think of is that the menu strip opens only if the user moves the mouse to the top of the screen or at least outside of your window. And when the user instead right-clicks into your window, something else happens, but not the menu strip.

In order to achieve this, you can dynamically change the RMBTRAP flag dependent on the mouse position. You have to activate WFLG_REPORTMOUSE and IDCMP_MOUSEMOVE. For ReAction you probably also have to code a IDCMP hook because IIRC IDCMP_MOUSEMOVE is filtered by window.class and not reported as WMHI event.

Another way to get control before the menu strip opens is IDCMP_MENUVERIFY. But this does not hinder the menu to open when you are done with the message.

zzd10h
zzd10h's picture
Offline
Last seen: 6 years 11 months ago
Joined: 2012-08-24 20:56
Thank you Thomas for your

Thank you Thomas for your reply.

"so why do you need mouse coordinates?"

Related to this topic that I opened too ;
http://www.os4coding.net/forum/solved-how-retrieve-gadget-id-wmhimousebuttons-or-windowappmsghook-hook

I need to know X/Y at RMB time to determine on which gadget/button I clicked with RMB button.

For example, I have a toolbar with 10 buttons of 5 pixels width each. My window is therefore 50 pixels width.

I can RMB on one of this button, save the X/Y, open a popupmenu and select "remove button".
Thanks to RMBTrap, I can scan my window to find which button is at X.

It works well but not when I try to use NewMenu (and therefore when I disable RMBTrap)

zzd10h
zzd10h's picture
Offline
Last seen: 6 years 11 months ago
Joined: 2012-08-24 20:56
I think that I found a

I think that I found a bypass.

I simply save the gadgetID, when my cursor is over my window.
Therefore even without RMBTrap, I always have the latest gadgetid just before RMB is pressed.

broadblues
broadblues's picture
Offline
Last seen: 4 years 8 months ago
Joined: 2012-05-02 21:48
Look up MENUVERIFY I think

Look up MENUVERIFY

I think this gives you option to cancel a system menu and open your popup instead depening on position.

{edit] I'm thining of the wrong thing, it doesn't do that.

Another option is to disable menus when the mouse is over certain section of your window and open popups there as required instead.

Yet another option might be to apply a qualifier for popups or use the Middlemose button.

I see Thomas beta me on most of those suggestions, should have read his post before jumping in!

broadblues
broadblues's picture
Offline
Last seen: 4 years 8 months ago
Joined: 2012-05-02 21:48
I think that I found a


I think that I found a bypass.

I simply save the gadgetID, when my cursor is over my window.
Therefore even without RMBTrap, I always have the latest gadgetid just before RMB is pressed.

Move the mouse quickly and you could be in trouble here.

zzd10h
zzd10h's picture
Offline
Last seen: 6 years 11 months ago
Joined: 2012-08-24 20:56
I will try tomorrow

I will try tomorrow nevertheless in my program, if I click RMB :
-I'm in my window (i inhibit menu opening outside of the window)
-I'm really on a gadget, I don't have gap between the objects.

It should work (in theory ;) )

Log in or register to post comments