Reputation: 3481
I've tried this:
actZoomReset.ShortCut := TextToShortCut('Ctrl+Num 0');
But this does nothing (ShortCut = 0).
EDIT:
If I try to set the value in the IDE (Ctrl+Num 0), directly in the ShortCut property, I get the error: "Invalid Property Value". If I double click on the Shortcut property, and then press "Ctrl" and "Numkey 0", it shows "Ctrl+Num 0" in the hotkey edit, and when I press enter, it shows "Ctrl+Ins" in the ShortCut field.
Actually
actZoomReset.ShortCut := TextToShortCut('Ctrl+Ins');
Will work. My question then becomes, will this work on other keyboards, or is this a quirk of my own keyboard? I'm using a Logitech G213. The numpad 0 has "Ins" under it.
I'm using Delphi 10.2 on Windows 10
Upvotes: 2
Views: 1370
Reputation: 109158
The simplest way is to set the action's short cut at design time using the Object Inspector:
But if you need to set this property programmatically, you can do
actZoomReset.ShortCut := ShortCut(VK_NUMPAD0, [ssCtrl])
(Typically, there is no need to adjust an action's non-state properties at runtime. The state properties are Visible
, Enabled
, and Checked
.)
Regarding your edit:
It sounds like you have accidentally turned off NUM LOCK. When NUM LOCK is ON (the default), the 0/INS key means 0. When NUM LOCK is off, it means INS.
To turn on NUM LOCK, press the key in the red circle. When NUM LOCK is on, the LED in the green circle will be on.
Upvotes: 5