Bug 147762 - Automatically assigned mnemonics not always set
Summary: Automatically assigned mnemonics not always set
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: framework (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: accessibility, needsDevEval
Depends on:
Blocks: Shortcuts-Accelerators
  Show dependency treegraph
 
Reported: 2022-03-04 10:44 UTC by Heiko Tietze
Modified: 2023-07-26 11:55 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Heiko Tietze 2022-03-04 10:44:54 UTC
Spin-off from bug 147667: when mnemonics are not hard-coded it will be assigned automatically. This fails if all letters of a string were used before.

For example the Paste Special dialog uses A for Transpose _All and L for Cance_l making the checkbox "All" not accessible. In this case we cannot prevent double allocation and should use any character.
Comment 1 Stéphane Guillou (stragu) 2023-07-25 13:15:34 UTC
According to bug 154389 comment 4, labels with no explicitly defined accelerator (in source or translated strings) are assigned one of the initial or final letters of its words if they are not already taken in that menu.

Rafael, do you have a code pointer for that?

Testing in a recent 24.2 master build, here are more example of commands that don't have an accelerator because all letters are taken:
- in French UI, Writer > Fichier > Signatures numériques
- in French UI, Writer > Formulaire > Ouvrir en mode ébauche; Focalisation automatique sur le contrôle; Contrôles de contenu

From bug 154389, an example where "inner" letters are available but not used:
- in English-US UI, Calc > cell with comment > context menu > Delete comment: could use O, M or N as they are not used elsewhere in the menu.

Already seen in OOo 3.3 with Edit > ImageMap missing an accelerator.

For improving the method, I imagine this process:

- If accelerator explicit with ~, use it
- If not:
  - (exclude special characters)
  - use first letter of word if available
  - if not available:
    - use any letter in the string that's not already used
    - if none available:
      - avoid letters already used by a submenu name (see bug 143184)
      - prioritise letters used the least

Hossein, wondering if this could be an easyHack?
Comment 2 Rafael Lima 2023-07-26 11:55:20 UTC
(In reply to Stéphane Guillou (stragu) from comment #1)
> Rafael, do you have a code pointer for that?

This seems to be the method used to generate mnemonics:
MnemonicGenerator::CreateMnemonic()

Located in:
/core/vcl/source/window/mnemonic.cxx