Num+ instead of NumPlus lazarus / 31-LCL ---------------------------------------------------------------------- Denis Bisson · 2016-12-05 12:39 Hi! Right now if we set a keyboard shortcut with keys like Num+, Num-, Num*, etc..., when the associated menu item is displayed the text that is display for the shortcut will be "NumPlus", "NumMinus", "NumMul"... From I've seen, this text is coming from function "GetSpecialShortCutName" in "lclproc.pas". Is there a way to change that to "Num+", "Num-", "Num*" ? I've changed it directly in "lclproc.pas" and recompile the application and I see it works but I can't request collaborators on a projects to change their Lazarus files... A few persons better like "Num+", "Num-", "Num*", etc. than "NumPlus", "NumMinus", "NumMul", etc. For example "Num*" will be recognized much better for a international user, he figure better the key, than "NumMul". Do you think author could change that? Or could have a kind of call back routine to change that text or is there already a way to do it? Thanks. Denis. ---------------------------------------------------------------------- howardpc · 2016-12-05 14:17 I think there might be backwards compatibility issues if the Lazarus sources were changed in the way you propose. Why not just use your own GetSpecialSCName() function, adapted from the original in LCLProc to suit your needs? ---------------------------------------------------------------------- Denis Bisson · 2016-12-05 14:33 Quote from: howardpc on December 05, 2016, 03:17:19 pmI think there might be backwards compatibility issues if the Lazarus sources were changed in the way you propose. Why not just use your own GetSpecialSCName() function, adapted from the original in LCLProc to suit your needs?   Hi howardpc!   Regarding the backward compatibility issue, I understand.   Sorry if I look stupid but how could I made the component drawing the menu to call my own GetSpecialShortcutName function? Note:  Regarding my own GetSpecialShortcutName it's already done and it is in fact how the situation came up and someone bring it to my attention. In our application in a page where we show the keyboard shortcuts of the application in a single table, we show "Num+", "Num-", etc. We did it three years before "GetSpecialShortCutName" was returning "NumMul" in Lazarus by the way (have the proof in control version  ), but we never heard back until recently where someone pointed us that in our table showing the shorcuts it was showing "Num*" and in the menu it was showing "NumMul"... Certainly we can change what we're showing in our table for "NumMul" and so on, but you know... Num+, Num*, etc. are better looking. So I am asking... ---------------------------------------------------------------------- AlexTP · 2016-12-08 00:37 IMO you are right, I typed in my LCL patch "NumMul" just as a guess. Try to replace to "Num*" and test how TextToShortcut works with string "Num*". Test also how "Ctrl+Alt+Num+" works with TextToShortcut. if it works, then try making the patch to Bugtracker. ---------------------------------------------------------------------- howardpc · 2016-12-08 11:41 Quote from: Denis Bisson on December 05, 2016, 03:33:26 pm  Sorry if I look stupid but how could I made the component drawing the menu to call my own GetSpecialShortcutName function? I don't know how you can do this, unless your platform supports ownerdrawn menus (which several do not). The LCL uses the underlying widgetset to draw the menus, so customisation is difficult (though perhaps not impossible if you are good at hacking). On Linux for instance, both gtk2 and qt show a NumMul shortcut as simply * (not Num* nor NumMul - in the IDE the Object Inspector shows the shortcut as NumMul using GetSpecialShortcutName). ---------------------------------------------------------------------- ASerge · 2016-12-10 03:28 Example of hacking: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function NewShortCutToText(ShortCut: TShortCut): string;var  ScanCode: UINT;  KeyName: array [0..255] of Char;  KeyNameLen: Integer;begin  Result := '';  ScanCode := MapVirtualKey(ShortCut, 0);  if ScanCode <> 0 then  begin    case ShortCut of      VK_PRIOR..VK_DOWN,      VK_INSERT, VK_DELETE,      VK_LWIN..VK_APPS:        ScanCode := ScanCode or $100;    end;    KeyName[0] := #0; // Emit warning: Local variable "KeyName" does not seem to be initialized    KeyNameLen := GetKeyNameText(ScanCode shl 16, KeyName, SizeOf(KeyName));    if KeyNameLen > 0 then    begin      SetString(Result, KeyName, KeyNameLen);      if (ShortCut and scShift) <> 0 then        Result := 'Shift+' + Result;      if (ShortCut and scCtrl) <> 0 then        Result := 'Ctrl+' + Result;      if (ShortCut and scAlt) <> 0 then      Result := 'Alt+' + Result;    end;  end;end; function RedirectProc(OldProc, NewProc: Pointer): Boolean;var  Code: packed record    Jmp: Byte;    Offset: LongInt; // Valid for x64 too  end;  NotUsed: PtrUInt;begin  Code.Jmp := $E9;  Code.Offset := PAnsiChar(NewProc) - PAnsiChar(OldProc) - SizeOf(Code);  NotUsed := 0; // Emit hint: Local variable "NotUsed" does not seem to be initialized  Result := WriteProcessMemory(GetCurrentProcess, OldProc, @Code, SizeOf(Code), NotUsed);end; and test: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormActivate(Sender: TObject);var  ShortCut: TShortCut;  L: TStringList;begin  L := TStringList.Create;  try    for ShortCut := $8 to $80 do      L.Append(Format('%.2x'#9'%s'#9'%s',        [ShortCut, ShortCutToText(ShortCut), NewShortCutToText(ShortCut)]));    L.Append(StringOfChar('-', 40));    Memo1.Text := L.Text;    if RedirectProc(@ShortCutToText, @NewShortCutToText) then    begin      for ShortCut := $8 to $80 do        L.Append(Format('%.2x'#9'%s'#9'%s',          [ShortCut, ShortCutToText(ShortCut), NewShortCutToText(ShortCut)]));      Memo1.Text := L.Text;    end;  finally    L.Free;  end;end; ---------------------------------------------------------------------- howardpc · 2016-12-10 10:31 @ASerge: Is MapVirtualKey() an OS-specific call? If not, where do we find it? ---------------------------------------------------------------------- ASerge · 2016-12-10 14:08 Quote from: howardpc on December 10, 2016, 11:31:34 am@ASerge: Is MapVirtualKey() an OS-specific call? Sorry, it Windows only (MapVirtualKey, GetKeyNameText, WriteProcessMemory, GetCurrentProcess) and x86 architecture (jmp near instruction).