Is it possible? For example, Notepad ++ does this, but just trying to assign it to components, such as actions or menu items, does not work. The event to which it is assigned simply does not fire.
So, I took my question to Google. Nada. Then I tried to perform various quick access functions, in this case TextToShortCut and ShortCutToText.
The first, TextToShortCut, converts the material as "Ctrl + A" (string) to the following 16-bit value:
(uint)A | (uint)Ctrl
Works fine, mostly. However, I noticed the following oddity:
// Try converting back and forward... TextToShortCut('Ctrl+/') = 16495 // That incorrect. It should be: Ord('/') or scCtrl = 16431 // Incorrect too ShortCutToText(16495) = 'Ctrl+/' // This is the shortcut the first line actually creates (Ctrl+o) Ord('o') or scCtrl = 16495 // wut? // Which is invalid, cause only caps are used ShortCutToText(16431) = ''
What's going on here? At the moment, I believe that the error lies in the final part of TextToShortCut: after processing the part before the + sign (in this case, "Ctrl"), it will try to find a shortcut for the remaining part ("/"). However, in its current form, the part after + should also be a valid label.
for Key := $08 to $255 do { Copy range from table in ShortCutToText } if AnsiCompareText(Text, ShortCutToText(Key)) = 0 then begin Result := Key or Shift; Exit; end;
So, because:
ShortCutToText('/') = 0 (failure) MapVirtualKey('/',MAPVK_VK_TO_VSC) = 0 (failure)
... the loop cannot detect '/' as a valid shortcut.
Is this some VCL error or am I missing something?
Here's a proof of concept (yes, I'm taking screenshots of the code, but merging this together with the component palette is faster than using this code):
Change 1:

Edit 2:
Manually assigning item 16431 to a menu item does not work.