MarkShark 27 Posted Wednesday at 01:29 PM (edited) I recently came across this older stack overflow question: TAction.SecondaryShortCuts is language specific. How to set it correctly? The question is from 2012 and regarding Delphi XE2. If I'm interpreting this correctly, if I set a secondary shortcut to "Ctrl+J" (in English) then it won't fire if my application is run in say, Germany? I must just be reading it wrong or maybe it's something that's changed since then? Thanks for any insights! Edited Wednesday at 01:30 PM by MarkShark clarifying my language Share this post Link to post
Lajos Juhász 292 Posted Wednesday at 01:54 PM In the official documentation there is no mention that it would be a language specific shortcut: Description Stores shortcuts (in addition to ShortCut) for triggering the action. Actions can execute in response to multiple shortcut key combinations. SecondaryShortCuts lists all the shortcut key combinations (other than the one specified by the ShortCut property) that can trigger the action. This lets you provide additional, secondary shortcuts. When the user types one of the key combinations listed in SecondaryShortCuts, the action's Execute method is called. Share this post Link to post
Anders Melander 1773 Posted Wednesday at 02:22 PM (edited) Secondary shortcuts are stored as strings in a TStringList so if whatever translation tool you are using supports TStringList then it can be localized. edit: I can see that the SO post you linked already explains all this and it wasn't what you asked about. My guess is that, yes, if the users locale is German then English shortcuts won't work. It pretty easy to test for your self; Just change the UI language in Windows. Edited Wednesday at 02:26 PM by Anders Melander Share this post Link to post
Lajos Juhász 292 Posted Wednesday at 02:28 PM According to the documentation the object property of the stringlist is used to handle the shortcuts not the text version: TCustomShortCutList is a descendant of TStringList, which manages a collection of strings. As such, TCustomShortCutList adds, deletes, and searches for shortcuts using their text representation. TCustomShortCutList stores shortcuts that correspond to a text representations as values of the Objects property for these strings. Do not change values of the Objects property, or the shortcut list will not operate correctly. Share this post Link to post
Anders Melander 1773 Posted Wednesday at 02:37 PM 6 minutes ago, Lajos Juhász said: According to the documentation the object property of the stringlist is used to handle the shortcuts not the text version The text is what get stored in the DFM. The actual shortcut is created from that and stored at run-time in the Objects pointer list: function TShortCutList.Add(const S: String): Integer; begin Result := inherited Add(S); Objects[Result] := TObject(TextToShortCut(S)); end; Share this post Link to post
Anders Melander 1773 Posted Wednesday at 02:43 PM 1 minute ago, Anders Melander said: TextToShortCut(S) TextToShortcut is the problem here, if you can call it that. It compares the shortcut text against some resourcestrings ("Shift+", "Ctrl+", etc.) and if those resourcestrings have been translated then the shortcut strings must also be translated. As far as I can tell (contrary to what I claimed above), if the OP isn't translating anything, then there should be no problem. I would test to make sure, though. 1 Share this post Link to post