Difference between revisions of "New LCL shortcut system"

From Lazarus wiki
Jump to navigationJump to search
(New page: This page collects ideas about improving system of shortcuts in LCL. ==Current state== TShortCut = Low(Word)..High(Word); // in classes.pp unit // virtual key codes VK_* Key := Shor...)
 
m (Fixed syntax highlighting)
 
(12 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
==Current state==
 
==Current state==
  
TShortCut = Low(Word)..High(Word); // in classes.pp unit
+
<syntaxhighlight lang=pascal>
 +
TShortCut = Low(Word)..High(Word); // in classes.pp unit
 
   
 
   
// virtual key codes VK_*
+
// virtual key codes VK_*
Key := ShortCut and $FF;  
+
Key := ShortCut and $FF;  
 
   
 
   
// key modifiers
+
// key modifiers
Meta    := ShortCut and $1000; // scMeta
+
Meta    := ShortCut and $1000; // scMeta
Shift  := ShortCut and $2000; // scShift
+
Shift  := ShortCut and $2000; // scShift
Control := ShortCut and $4000; // scControl
+
Control := ShortCut and $4000; // scControl
Alt    := ShortCut and $8000; // scAlt
+
Alt    := ShortCut and $8000; // scAlt</syntaxhighlight>
 +
 
 +
Unused bits in TShortCut: $0F00
 +
 
 +
==Requirements==
 +
# backward compatibility
 +
#* accept current TShortCut format
 +
#* new format can use only unused bits in current TShortCut format
 +
# secondary, ternary shortcuts
 +
# platform-specific shortcuts (E.g. {{keypress|Ctrl|C}} under Windows, {{keypress|Cmd|C}} under Mac OS X)
 +
# shortcuts also with characters (E.g. {{keypress|Cmd|?}})
 +
 
 +
==Conclusion==
 +
* create list of extra shortcut data under TApplication (TLCLShortCutList)
 +
* the TShortCut value would be "an index" to one item in this list, unused bits can distinguish different shortcuts with same key code (0 will be reserved for old version)
 +
* modify shortcut handling in TApplication, TForm, TAction and TMenuItem
 +
** check for character shortcuts in IntfUTF8KeyPress
 +
* add functions like ShortCutToText to TApplication
 +
* modify TShortCut component editor
 +
 
 +
===TLCLShortCut class===
 +
* index - TShortCut with modified unused bits
 +
* priority list of TLCLShortCutItem
 +
** key modifiers
 +
** platform modifiers
 +
** key or UTF-8 character
 +
 
 +
[[Category:LCL]]
 +
[[Category:Proposals]]

Latest revision as of 09:10, 21 February 2020

This page collects ideas about improving system of shortcuts in LCL.

Current state

TShortCut = Low(Word)..High(Word); // in classes.pp unit
 
// virtual key codes VK_*
Key := ShortCut and $FF; 
 
// key modifiers
Meta    := ShortCut and $1000; // scMeta
Shift   := ShortCut and $2000; // scShift
Control := ShortCut and $4000; // scControl
Alt     := ShortCut and $8000; // scAlt

Unused bits in TShortCut: $0F00

Requirements

  1. backward compatibility
    • accept current TShortCut format
    • new format can use only unused bits in current TShortCut format
  2. secondary, ternary shortcuts
  3. platform-specific shortcuts (E.g. Ctrl+C under Windows, Cmd+C under Mac OS X)
  4. shortcuts also with characters (E.g. Cmd+?)

Conclusion

  • create list of extra shortcut data under TApplication (TLCLShortCutList)
  • the TShortCut value would be "an index" to one item in this list, unused bits can distinguish different shortcuts with same key code (0 will be reserved for old version)
  • modify shortcut handling in TApplication, TForm, TAction and TMenuItem
    • check for character shortcuts in IntfUTF8KeyPress
  • add functions like ShortCutToText to TApplication
  • modify TShortCut component editor

TLCLShortCut class

  • index - TShortCut with modified unused bits
  • priority list of TLCLShortCutItem
    • key modifiers
    • platform modifiers
    • key or UTF-8 character