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:

  1. 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:
    1. Difficulty of determining which the labels are for each window (and the same label is sometimes used in different windows).
    2. Errors in their assignment (duplicity), when the input number is big.
    3. The non assignment of the biggest number possible of these hotkeys, when the input number is big.
  2. To assign and remove in runtime the hotkeys for the controls belonging to containers that are not visible simultaneously: some panels and TTabSheet.
  3. Non-support for automatic hotkey setting for T(Tnt)MenuItem for non-Latin writing.

The translator

He/she sets previously:

  1. The valid characters (for example: abcdef...).
  2. 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,....).

The program

A. Creates a label list that orders in the following way:

  1. 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.
  2. 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.

  3. 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.
  4. 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:

  1. Exclude of this list the labels corresponding to some buttons (or controls):
    1. OK, or the default button, that is activated with the Intro key.
    2. Cancel, that is activated with the Esc key.
    3. Help, that is activated with the F1 key.
    4. Others (procedure HotkeysExclCAdd).
  2. Preset a high priority (0) for any control (procedure HotkeysHighPriorityCAdd).

B. For each label uses the following priorities for the character assignment:

  1. The first character of the first word.
  2. The second character of the first word.
  3. The first character of some of the following words, in order of appearance of the same ones.
  4. The characters third to last of the first word.
  5. The characters second to last of the following words, in order of appearance of the same ones.
  6. Any contained character in the list of words to ignore, for appearance order.

The assignment

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:

  1. The group hotkey is excluded if all the radio buttons have a hotkey assigned.
  2. 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.