Recent

Author Topic: TMainMenu: Hotkeys active with visible is false  (Read 2172 times)

jamie

  • Hero Member
  • *****
  • Posts: 6888
Re: TMainMenu: Hotkeys active with visible is false
« Reply #15 on: March 02, 2022, 11:46:56 pm »
You have some choices.

Using the FORM's key handler and setting the KeyPreview := True allows you to view all key presses

Then while in the OnKeyDown event of the form, you can inspect the Menu.Parent and if it's set to Nil, then it's assumed it is not visible.

At this point you can loop through the menu items and subitems looking for the match shortcut.

using "KeyToShortCut" gives you the value of the shortcut used in each menu.

when you find the menu that has this shortcut then execute its OnClick handler if it is valid .


 or you could just simply check all these values while in the forms event but then if you decide to change the shortcut key values in the menus you then would need to match them in the form's Onkeydown. This is why I suggest looping through the menu using only one list..

 Its your party.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018