New LCL shortcut system: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | This page collects ideas about improving system of shortcuts in LCL. | |
| 2 | 2 | ||
| 3 | 3 | ## Current state | |
| 4 | 4 | ||
| 5 | 5 | ``` pascal | |
| 6 | 6 | TShortCut = Low(Word)..High(Word); // in classes.pp unit | |
| 7 | 7 | ||
| 8 | 8 | // virtual key codes VK_* | |
| 9 | 9 | Key := ShortCut and $FF; | |
| 10 | 10 | ||
| 11 | 11 | // key modifiers | |
| 12 | 12 | Meta := ShortCut and $1000; // scMeta | |
| 13 | 13 | Shift := ShortCut and $2000; // scShift | |
| 14 | 14 | Control := ShortCut and $4000; // scControl | |
| 15 | 15 | Alt := ShortCut and $8000; // scAlt | |
| 16 | 16 | ``` | |
| 17 | 17 | ||
| 18 | 18 | Unused bits in TShortCut: \$0F00 | |
| 19 | 19 | ||
| 20 | 20 | ## Requirements | |
| 21 | 21 | ||
| 22 | 22 | 1. backward compatibility | |
| 23 | 23 | - accept current TShortCut format | |
| 24 | 24 | - new format can use only unused bits in current TShortCut format | |
| 25 | 25 | 2. secondary, ternary shortcuts | |
| 26 | - | ||
| 27 | - | ||
| 26 | + | 3. platform-specific shortcuts (E.g. `Ctrl`+`C` under Windows, `Cmd`+`C` under Mac OS X) | |
| 27 | + | 4. shortcuts also with characters (E.g. `Cmd`+`?`) | |
| 28 | 28 | ||
| 29 | 29 | ## Conclusion | |
| 30 | 30 | ||
| 31 | 31 | - create list of extra shortcut data under TApplication (TLCLShortCutList) | |
| 32 | 32 | - 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) | |
| 33 | 33 | - modify shortcut handling in TApplication, TForm, TAction and TMenuItem | |
| 34 | 34 | - check for character shortcuts in IntfUTF8KeyPress | |
| 35 | 35 | - add functions like ShortCutToText to TApplication | |
| 36 | 36 | - modify TShortCut component editor | |
| 37 | 37 | ||
| 38 | 38 | ### TLCLShortCut class | |
| 39 | 39 | ||
| 40 | 40 | - index - TShortCut with modified unused bits | |
| 41 | 41 | - priority list of TLCLShortCutItem | |
| 42 | 42 | - key modifiers | |
| 43 | 43 | - platform modifiers | |
| 44 | 44 | - key or UTF-8 character | |
| 45 | 45 | ||
| 46 | 46 | --- | |
| 47 | 47 | *From the Free Pascal wiki, page "New LCL shortcut system", as it stood on 2020-02-21 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 48 | 48 | Category: LCL | |
| 49 | 49 | Category: Proposals |
