Hotkey automatic assignment (Alt-character key sequence) for the labeled controls
The program carries out the assignment automatically, in runtime, on opening (or later) any window, for the biggest number possible of labeled controls (labels with FocusControl, buttons...) and, optionally, menus.
The reason is:
- To avoid this assignment task to the program translator (we think of the translation with the po files [external to the program]), due to the problems that it bears it:
- Difficulty of determining which the labels are for each window (and the same label is sometimes used in different windows).
- Errors in their assignment (duplicity), when the input number is big.
- The non assignment of the biggest number possible of these hotkeys, when the input number is big.
- To assign and remove in runtime the hotkeys for the controls belonging to containers that are not visible simultaneously: some panels and TTabSheet.
- Non-support for automatic hotkey setting for T(Tnt)MenuItem for non-Latin writing.
He/she sets previously:
- The valid characters (for example: abcdef...).
- The list of words to ignore, in first instance, as the articles, conjunctions, etc. (for example [and separating them for comas]: the,and,or,with,if,....).
A. Creates a label list that orders in the following way:
- Page: it sets a 0 for the inputs that are not inside a PageGroup, otherwise, a 1 for those that are in the first TabSheet, a 2 for second one and so forth. The assigned characters of a TabSheet will be able to this way to repeat in the other TabSheet.
- Priority: it sets:
0: For the first element of the window, GroupBox or TabSheet; and for the PageGroup labels.
2: For any radio button.
1: For the other inputs.
- Level: it sets a 0 if the iput is not inside any GroupBox or TabSheet, a 1 if it is inside 1 GroupBox or TabSheet, and so forth.
- Number of different characters: It is assigned this way, in the first place, the labels that have less different characters and that therefore (a priori) they will be more difficult of assigning to avoid repetitions. If the translator believes opportune to assign a certain hotkey to a label, non advisable option, that decision will be respected (then the number of different characters will be 0).
The programmer can:
- Exclude of this list the labels corresponding to some buttons (or controls):
- OK, or the default button, that is activated with the Intro key.
- Cancel, that is activated with the Esc key.
- Help, that is activated with the F1 key.
- Others (procedure HotkeysExclCAdd).
- Preset a high priority (0) for any control (procedure HotkeysHighPriorityCAdd).
B. For each label uses the following priorities for the character assignment:
- The first character of the first word.
- The second character of the first word.
- The first character of some of the following words, in order of appearance of the same ones.
- The characters third to last of the first word.
- The characters second to last of the following words, in order of appearance of the same ones.
- Any contained character in the list of words to ignore, for appearance order.
It can assign, optional and automatically (using the mentioned criterions A.4 and B), the hotkeys for the menu items. Then you must set T(Tnt)MainMenu.AutoHotkeys := maManual.
Previously the hotkeys of the menu headings are excluded. Then the criterions of the list sorting (A) and the selection for each label (B), described previously, are used for to set the hotkeys to dialog inputs.
Before concluding each Page, a special confirmation is made with the radio buttons:
- The group hotkey is excluded if all the radio buttons have a hotkey assigned.
- All the radio-buttons hotkeys are excluded if some of their labels doesn't have a hotkey assigned (making uniform their presentation: either all or none).
This way, and in the page 0 case, the program can reuse that character (case1, or those characters, case 2) for the TabSheet inputs.