Recent

Author Topic: Shift+Ctrl+Alt order in ShortCutToText  (Read 1143 times)

daniel_sap

  • Full Member
  • ***
  • Posts: 115
Shift+Ctrl+Alt order in ShortCutToText
« on: August 29, 2025, 05:43:24 am »
Hi,
I use ShortCutToText function in LCLProc unit
and see that it returns the ShortCut text with 'Shift' first which is a little bit strange to me.
I checked various shortcut documentation and everywhere is Ctrl is before the Shift.
Do you know what could be the reason for working this way

Lazarus 4.0RC1 (rev t-fixes-4-58-g43d904ed50) FPC 3.2.2 x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 18672
  • Jungle wars. And failing health it seems.
Re: Shift+Ctrl+Alt order in ShortCutToText
« Reply #1 on: August 29, 2025, 06:27:29 am »
Do you mean that Lazarus has a particular order? Then that is wrong, but I don't think that is the case.
The only order should be any special keys first and selector last.
alt-ctrl-shift shift-ctrl-alt and crtl-alt-shift should be all the same.
Think of it as a set (and it probably is).
« Last Edit: August 29, 2025, 06:30:40 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

daniel_sap

  • Full Member
  • ***
  • Posts: 115
Re: Shift+Ctrl+Alt order in ShortCutToText
« Reply #2 on: August 29, 2025, 03:35:07 pm »
Most of the ShortCut listings I checked, even the Lazarus one https://wiki.freepascal.org/Lazarus_IDE_Shortcuts
they use the Ctrl first and then the Shift
For example from the Lazarus IDE Shortcuts documentation
Ctrl-Shift-F11    misc    project options

However this is the code int LCLProc

Code: Pascal  [Select][+][-]
  1. function ShortCutToTextGeneric(ShortCut: TShortCut; Localized: boolean): string;
  2. var
  3.   Name: string;
  4. begin
  5.   Result := '';
  6.   Name := KeyCodeToKeyString(ShortCut and $FF, Localized);
  7.   if Name <> '' then
  8.   begin
  9.     if ShortCut and scShift <> 0 then Result := Result + KeyCodeToKeyString(scShift, Localized);
  10.     if ShortCut and scCtrl <> 0 then Result := Result + KeyCodeToKeyString(scCtrl, Localized);
  11.     if ShortCut and scMeta <> 0 then Result := Result + KeyCodeToKeyString(scMeta, Localized);
  12.     if ShortCut and scAlt <> 0 then Result := Result + KeyCodeToKeyString(scAlt, Localized);
  13.     Result := Result + Name;
  14.   end;
  15. end;
  16.  
which puts first the Shift.

When I use this function it outputs 'Shift' first.
Now I changed it with my custom function, but was wondering if there is specific reason behind it.

And this function is used for the entire Lazarus IDE.
If you open Lazarus IDE and click on the File menu, you will see 'Save All    Shift+Ctrl+S'
« Last Edit: August 29, 2025, 03:39:17 pm by daniel_sap »

Thaddy

  • Hero Member
  • *****
  • Posts: 18672
  • Jungle wars. And failing health it seems.
Re: Shift+Ctrl+Alt order in ShortCutToText
« Reply #3 on: August 29, 2025, 04:13:47 pm »
I tested. It is what I said, you can also press ctrl-shift-s
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

n7800

  • Hero Member
  • *****
  • Posts: 589
  • Lazarus IDE contributor
    • GitLab profile
Re: Shift+Ctrl+Alt order in ShortCutToText
« Reply #4 on: August 29, 2025, 04:49:32 pm »
In theory, the order of modifier keys is never strictly defined, because any order always implies the same key combination. So it is different everywhere:
* in constants:
    * TShiftStateEnum
    * scShift..scAlt
* functions:
    * ShortCutToText(scAlt + scCtrl + scShift + VK_RETURN) // 'Shift+Ctrl+Alt+Enter'
    * KeyAndShiftStateToKeyString(VK_RETURN, [ssMeta, ssAlt, ssCtrl, ssShift]) // 'Ctrl+Alt+Shift+Meta+Enter'
* and as a consequence in the GUI (see attachments for the Object Inspector and the Shortcut Grab Box dialog)
* in the documentation and so on...

As for unification, I am personally for it, but we will have to check how it will affect compatibility, and whether it is worth it. I think the developers will not take risks because of this, and are unlikely to accept the patch.

AlexTP

  • Hero Member
  • *****
  • Posts: 2665
    • UVviewsoft
Re: Shift+Ctrl+Alt order in ShortCutToText
« Reply #5 on: August 29, 2025, 06:29:23 pm »
The parsing code of TextToShortcut is stable, is must handle both 'Ctrl+Alt+Shift+A' and 'Shift+Alt+Ctrl+A'. AFAIR.
So, unifying of order is good.

 

TinyPortal © 2005-2018