BlitzMax and F10

Started by LT, January 20, 2019, 18:52:19

Previous topic - Next topic

LT

Sorry if this has been asked many times before.  I've noticed that the Windows F10 key, which has the default behavior of selecting the menu for a given window, seems to be active in my application even though I created the window without the WINDOW_MENU flag.

Has anyone had this issue before?  Is there some way to turn that off?

Henri

Hi,

I don't believe this has been asked before.

What I have read is that this is the default behavior in Windows, so pressing F10 is equivalent of Alt-key: This activates the menu.

Typical solution for this would be to intercept the F10 key press somehow. MaxGui doesn't grant access to low level key presses directly, but one solution would be to use..

Code (blitzmax) Select

SetHotKeyEvent(KEY_F10, 0)

'And to catch event
Select EventID()
Case EVENT_HOTKEYHIT DebugLog "Hot!"


Ps. There is a disclaimer in the docs saying
QuoteTo avoid any unexpected behavior, make sure that the window specified was created with the WINDOW_MENU style flag

Not sure what it means, but if menus are used in window then best use the menu-flag.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

LT

#2
Hi Henri, thanks for your response.

I'm not using the WINDOW_MENU flag because I don't want menus.  Turned out that hitting F10 still triggers APP_SUSPEND and APP_RESUME even without them.

There's no easy built-in way to do it that plays nicely with polledinput, as far as I can tell.  However, I did find out how to intercept the key and implement a workaround (using SetWindowsHookExA).

NOTE: I was unaware of EVENT_HOTKEYHIT.  Perhaps it would work...

FOLLOW UP: EVENT_HOTKEYHIT worked, but not sure it would handle all cases, since what I'm trying to do is make ANY key available to the player (down events, too).  Ultimately, I may have to put together my own, simpler polledinput that just tracks keys and times.