How to disable TAction.Shortcut or TMenuItem.Shortcut?

I am developing a Word addin, and somehow the shortcuts defined in TAction.ShortCut always fire more than once, and it’s hard for me and hard to solve, so I resorted to the TForm.OnKeyDown event and cleared all the TAction.ShortCut, this approach works OK, except that the shortcuts do not appear in the corresponding menu items, but I want them to appear in these menu items.

So, I come to this idea: set the values ​​for TMenuItem.Shortcut so that the program can show the label hint to the end user and does not allow VCL to process these labels, instead process them in TForm.OnKeyDown. So my question is how to disable TAction.Shortcut or TMenuItem.Shortcut? Thank you in advance.

+3
source share
3 answers

For starters, you have a property Enabledon TActionand TMenuItem. Just set it to False.

Then, one of the possible reasons for triggering your event more than once is that you can use Application.ProcessMessages; or at least the poorly written component you use does this. You should be very wary of using this Delphi function, as it can cause a "re-entry" code (unintended recursion).

+1
source

The root cause of the problem is events that are fired more than once. You could try to solve this problem, but I would suggest:

  • Place the breakpoint in the event handler.
  • [CTRL+ALT+S] , , , .
  • , .
  • , .
0

( ): , TAction , TAction, ShortCut . . .

VCL, Delphi "" .

0

Source: https://habr.com/ru/post/1725377/


All Articles