July 21, 2019, 04:23:59 AM

Author Topic: BlitzMax and F10  (Read 302 times)

Offline LT

  • Jr. Member
  • **
  • Posts: 28
BlitzMax and F10
« on: January 20, 2019, 06:52:19 PM »
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?

Offline Henri

  • Full Member
  • ***
  • Posts: 206
Re: BlitzMax and F10
« Reply #1 on: January 20, 2019, 10:34:23 PM »

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
  1. SetHotKeyEvent(KEY_F10, 0)
  3. 'And to catch event
  4. Select EventID()
  5.         Case EVENT_HOTKEYHIT    DebugLog "Hot!"

Ps. There is a disclaimer in the docs saying
To 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.

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

Offline LT

  • Jr. Member
  • **
  • Posts: 28
Re: BlitzMax and F10
« Reply #2 on: January 20, 2019, 11:22:38 PM »
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.