I'm using a Delphi TActionList, with Shortcut Keys for some actions.
I want to prevent certain actions from being triggered multiple times by keyboard auto-repeat, but I do not want to affect auto-repeat operation globally. What's the best way of doing this?
Clarification: I still need to handle multiple fast keypresses - it's only the keypresses generated by auto-repeat that I want to ignore.
You can drop TTimer, set TTimer.Interval to value you want (1000 = 1sec), then in TActionList do something like:
Also don't forget to disable timer in Timer.OnTimer.
You can save the last time an action is used and ignore it if the time in between is too short. For a single action you can do like:
You can combine this with the solution of dmajkic to get a more generic aproach. And if you are really ambitious, you can create a new version of TAction/TActionlist.
Intercept the WM_KEYDOWN messages, and look at bit 30 to see if it is auto-repeating. If it is, just don't pass on the message as usual and it will not be seen.
You may need to enable form key-preview to make this work.