Preventing the ALT key from triggering menus...

BlitzMax Forums/MaxGUI Module/Preventing the ALT key from triggering menus...

Damien Sturdy(Posted 2006) [#1]
Hi All.

When I press ALT in my app, it is supposed to rotate the camera, however, I need to use maxGUI for menu's.

What I'd like to do is prevent the ALT key from pausing my app and waiting for me to click on the menu items.

How can I do this?


Space_guy(Posted 2006) [#2]
uuuhg. i had the same problem. never did solve it though. Hope someone else did


Damien Sturdy(Posted 2006) [#3]

never did solve it though



Darnit! :(


fredborg(Posted 2006) [#4]
If your canvas (assuming you are using a canvas) pressing 'alt' will generate an EVENT_KEYDOWN when the canvas is the active gadget.

You could possibly use ActivateGadget to make it more or less permanently active.


AdrianT(Posted 2006) [#5]
yeah we have Ogre3D running in a Bmax canvas. The problem were having is that were using ALT as our camera mouselook control hotkey in our editor app, which works in a similar fashion to 3dsmax.


Damien Sturdy(Posted 2006) [#6]
I'm afraid the "activategadget" idea doesnt work, the window is frozen before the code is executed :(

Thanks for the comment though, anything helps!!!


Dreamora(Posted 2006) [#7]
Normally I would say: use Hotkey event. But depending on what you want to do with the pressed ALT button this won't work.

But a different idea could be: if canvas is active and mouse within canvas, disable window menus.


Damien Sturdy(Posted 2006) [#8]
hmm, good idea, but i've tried this.

The window is still frozen when no menus actually exist, I can stop this from happening by not using the "Window_TitleBar" flag when creating the window itself, but then, who wants to do that? :(

Thanks for your help guys, any more ideas let me know :)


Dreamora(Posted 2006) [#9]
Just tried it now.

If you handle the input through an eventhook you can easily use alt. Because if you use a mouse button while you are on alt, the menu won't be fired (at least XP Pro SP2)

Here is my testcode, perhaps I missed something:




Damien Sturdy(Posted 2006) [#10]
hmm, see the problem is that while it does know ALT has been pressed, it then highlights the menu's and the mouse information is no longer updated etc... until you click on the canvas. This is the behaveor im trying to stop if at all possible.

Thanks for looking into it for me Dreamora :)


Dreamora(Posted 2006) [#11]
If you want to have ALT for cam control, the canvas must be active anyway or at least the mouse must be over it (which is why I enable it on enter), because mouse events *which includes MOUSEMOVE* are only fired by Canvas and Panel with PANEL_ACTIVE flag.

Don't think you can disable this UI core behavior, as you can't stop Cacao from doing some stuff as it does them.
But you can prevent happening it by enable the "core action" gadget. If you want to use ALT / CTRL to have mouse based camera control, the mouse will be over the canvas anyway, so using the mouseenter to enable the gadget seems to be quite usable solution. If you want it to continue even outside the canvas, you will need to fill the window with a panel with PANEL_ACTIVE flag anyway or you won't get mousemove updates anymore.


Damien Sturdy(Posted 2006) [#12]
Hmm, thanks for the insight. I figured it might be hard to do- Guess i may have to go without maxgui for now, or find a working alternate control system- activating the gadgets doesnt stop it. Bummer.

Thanks again though :)


fredborg(Posted 2006) [#13]
Doesn't this work?



Damien Sturdy(Posted 2006) [#14]
hmm, not sure thats any different from before- interesting bit of code there.

The only problem with these bits of code is that the code execution stops as soon as alt is pressed then removed, because the menu is hilighted.

I will play with it again a bit tonight, maybe i can fathom something out.

The next thing I will need to do is grab an image of the canvas, which for some reason doesn't work when it it used as a render target from another lib

Thanks guys.


[edit]


Fredborg, I will try that code out when I get home.


Damien Sturdy(Posted 2006) [#15]
Fredborg- Nope, not sure what your code is doing either hehe :) cheers for the help though.


fredborg(Posted 2006) [#16]
Press and hold alt and use the mouse to pan, rotate and scale. I was under the impression that's what you needed?


Damien Sturdy(Posted 2006) [#17]
Ah lol, well, I already have all that working you see, but as soon as you let go of alt, the menu is hilighted and the app is paused. thats what I need to stop, if possible. Doesn't look like it is though.

Thanks for your efforts though mate, Much apreciated.


fredborg(Posted 2006) [#18]
Why do you need to stop that? Surely being able to access the menu by keyboard is something you don't want to disable.


Damien Sturdy(Posted 2006) [#19]
its a specific app that needs to use the ALT key to control the camera. it would probrably be best if a quick tap of the alt key triggers menu's, but the functionality is more crippled by the behaveor.

We are creating a CAD application basically. the control is similar to that of 3DS Max.


fredborg(Posted 2006) [#20]
On my machine the example I gave works exactly the same as 3dsmax.


impixi(Posted 2006) [#21]
Okay, here's a rough workaround example:



Basically you must utilise a style-less sub-window to 'trap' the ALT keyup event so it's not handled by the main window's menu.

You will need to implement decent EVENT_WINDOWMOVE and EVENT_WINDOWSIZE event handling code.

If your target platform is Windows only, you may need to utilise the Win32 API for a better solution.


Damien Sturdy(Posted 2006) [#22]
Thanks, that works... In fact Chris tried this method, and the problem is that the windows dont update until you let go of the button. if blitz didnt behave like this, the solution would be perfect :-)

Nice bit of code there cheers!