using complex shortcuts with TAction lazarus / 31-LCL ---------------------------------------------------------------------- EganSolo · 2015-11-19 00:19 Guys, I'd like to use shortcuts such as Ctrl+T+N or Ctrl+T Ctrl+N together in one action. Can this be done? I suppose one way to do this is to implement the OnKeyPress event of the form and write a delegator to invoke the right action based on the key combos... but before I go ahead and code this, I wanted to make sure I wasn't missing an obvious easy way to assign these types of key combos to actions? Thanks for any help you might have on this! ---------------------------------------------------------------------- howardpc · 2015-11-19 14:20 AFAIK the ShortCut and SecondaryShortcuts properties of TAction are restricted to use of a single keyboard key (with optional Ctrl/Shift/Alt/Meta modifiers), as currently programmed, because TShortcut is basically an alias for a range of word values. The word type is large enough to accommodate all common keycode combinations, provided they are formed by 'and'ing a single key code with just one, two or three of the limited range of modifier constants. A word could not accommodate the full range of values resulting from all possible keycode combinations of two different keyboard keys. The Lazarus IDE, on the other hand, defines its own TIDEShortcut record (in idecommands.pas). This lets IDE users issue two-key- sequence commands, such as the old Wordstar-compatible Ctrl+K,B etc. in the editor to specify a single command action in response to a two- key combination. However, the IDE designers have had to go to the trouble of providing an editor for these two-key combinations, as well as a response mechanism in the IDE which gets notified if such a two-key sequence is pressed. ---------------------------------------------------------------------- EganSolo · 2015-11-20 05:22 Howard, Thanks for this great explanation! Very helpful! Do you know if the TIDEShortcut record and the editor for the two-key combos are easy to lift out of the Lazarus IDE and included into our own code? In the meantime, I've implemented the OnKeyUp event of the Form and that works fine. Incidentally, it seems that the OnShortCut event is broken; it does not handle key combos such as Ctrl+Shift+T or I must really not understand how one goes about implementing it. I caught some code from Delphi but that does not work, and could not find an example implementing the Onshortcut event. Thanks for the detailed response; much appreciated. ---------------------------------------------------------------------- howardpc · 2015-11-20 09:00 Quote from: EganSolo on November 20, 2015, 06:22:14 amDo you know if the TIDEShortcut record and the editor for the two-key combos are easy to lift out of the Lazarus IDE and included into our own code? What is "easy"?  Such code is not written in the first instance to be pluggable in the 'black box' sense of being immediately transferrable outside the IDE. I'm sure it was written to take advantage of whatever the IDE already provides in terms of extended keystroke and shortcut support. It depends, for instance, on the presence of the Command property in TMenuItem (I don't know if this is present in Delphi or not). But that's just from a cursory look at the code. Even if the code is not immediately useful to you as it stands, there is no doubt that it is well designed and very reliable. Thousands of people are using it in anger every day when using the IDE. So studying the code will point you in the right direction, and give you good ideas, even if you have to adapt it somewhat for your purposes.