06 October 2023, 02:37 | #1 |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
How to trap or not trap right mouse button based on location?
Hello. Does anyone know how to make it such that when right mouse button is pressed outside of the window, the top menu appears, and while if it is pressed within the window it gets sent as an IDCMP event.
|
06 October 2023, 06:06 | #2 |
Coder/webmaster/gamer
Join Date: Oct 2001
Location: Canberra/Australia
Posts: 2,651
|
You can use IDCMP_MENUVERIFY for this; your program can then decide whether to allow the menu to open or not based on the MouseX and MouseY coordinates.
|
06 October 2023, 09:12 | #3 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,245
|
As said, MENUVERIFY is supposed to do that, see the intuition chapter of the RKRM Libraries. However, be prepared that MagicMenu does not handle this situation gracefully. It is a MagicMenu defect.
|
06 October 2023, 11:01 | #4 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,803
|
Well the source code is available so it can be fixed.
|
06 October 2023, 12:13 | #5 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,245
|
The source code is not the issue. The issue is the intuition state machine any program outside of intuition cannot access or impact. Thus, MagicMenu *cannot* do this correctly by any means, that's not anyone's fault.
|
06 October 2023, 12:24 | #6 |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 532
|
I tried, but you can't reproduce what Intuition does when the "menu verify" operation is in effect.
Once you receive an IDCMP_MENUVERIFY event, Intuition will let the event linger until you either reply the message with your choice (show the menu, or don't show the menu) or the event's time is up in which case the default behaviour will be to show the menu. The behaviour has an additional layer to it, too, which depends upon whether or not your window is the currently active one. Intuition is in a much better position to know when the active window changes. MagicMenu can only poll the IntuitionBase->ActiveWindow pointer and "hope" for the best. If this weren't already enough of a challenge, Intuition can take a long view of what Windows are currently also asking for the menu verification deal on the same screen. Only one of them (the active one, if there is one) can cancel the operation, the others don't get to play yet. This is a remarkably complex feature under the hood and, if memory serves, Intuition V33 could be accidentally tripped up by it and cause the state machine to hang. Your chances of making this feature work smoothly depend upon using a maximum of 1 window on your own custom screen Deluxe Paint made good use of menu verification back in the day, but you don't have to use it to get the same effect. For example, you can try to change the WFLG_RMBTRAP flag of your Window as needed, but you have to do this whenever the mouse moves and your Window is the active one. This can be a simpler alternative, but it is no full replacement for IDCMP_MENUVERIFY |
06 October 2023, 14:33 | #7 | |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Quote:
Also, why do you say "Your chances of making this feature work smoothly depend upon using a maximum of 1 window on your own custom screen"? Why is this so? |
|
06 October 2023, 15:42 | #8 | ||
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 532
|
Quote:
Intuition may notify you before it will transition into the menu rendering state. You will have to decide whether to let the menu rendering continue or not, you will also have to do this quickly before the default behaviour catches without you having a chance to make it something else. You may receive this message at a point when your window is no longer active (all input events are asynchronous by nature, as is Intuition's remit to react to these events), which makes this even more "unreliable". I struggle to find a compelling use for the IDCMP_MENUVERIFY feature, really, except that Intuition is doing much of the work for you which you would otherwise have to do all by yourself, should you rely upon the WFLG_RMBTRAP flag to be set/cleared as needed. Tinkering with WFLG_RMBTRAP is more easily accomplished. You clear the flag when the mouse position within your window requires that a right mouse button click reveals the menu, you set the flag otherwise. You do need to enable mouse movement reports with IDCMP_MOUSEMOVE just so that you can change the WFLG_RMBTRAP flag as needed. Note that due to how the events are processed, the user may click the right mouse button and fail to see the menu appearing. If the mouse is moved quickly, your program may not be able to update the WFLG_RMBTRAP flag state in sync with where the mouse pointer is when you process the event. Quote:
The use IDCMP_MENUVERIFY worked very well for programs such as Deluxe Paint, which only ever opened a single Window on the Screen for painting or using the tool box/magnifier, etc. |
||
07 October 2023, 08:18 | #9 | |
Registered User
Join Date: May 2022
Location: Adelaide, South Australia, Australia
Posts: 208
|
Quote:
Again, thanks for your help. |
|
08 October 2023, 11:14 | #10 | ||||
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,648
|
Quote:
Reasons to Use Menu Verify Quote:
Quote:
Quote:
|
||||
08 October 2023, 14:21 | #11 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,245
|
Quote:
First of all, I would consider it "not nice" if a program breaks with the user interface style that is otherwise consistent with all other programs. If there are special right-click menus in one particular program where a menu opens in a place intuition does normally not open a menu then that makes the user experience quite inconsistent. Second, the problem with the RMB trap is that at the time you change the flag, it may already be "too late" and intuition may already be in the progress with rendering the menu, so you cannot be sure that you do not get a MENUPICK instead of a mouse button event. MENUVERIFY excludes that by intuition explicitly asking *at the time it processes the event* what precisely it should do. So the concept of MENUVERIFY is in that sense a lot better integrated into the intuition system. |
|
09 October 2023, 08:15 | #12 |
Registered User
Join Date: Nov 2015
Location: Italy
Posts: 191
|
It's better to use WLFG_RMBTRAP. The docs themselves discourage use in most cases, except the rare cases like where programs really want to render directly to screen bitmap (instead of window) or things like paint programs which change palette and menu could be unreadable, so the program needs need to temporarily change palette while menus are open to make it readable.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mouse Trap - Why is the mouse trapped? | AmigaGroningen | support.WinUAE | 2 | 11 December 2016 09:08 |
FIXED: Venus The Fly Trap (TRAP #0) & NOVBRMOVE INFO | Retro-Nerd | project.Killergorilla's WHD packs | 10 | 01 November 2007 23:42 |
Mouse Trap/Mouse Quest | Audio Snow | support.Games | 2 | 25 August 2007 07:09 |
Mouse Trap | RickD | HOL contributions | 1 | 01 October 2006 17:10 |
ANy news on Treasure Trap / Death Trap | tomcat666 | request.Old Rare Games | 2 | 26 March 2002 07:08 |
|
|