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
: high normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: accessibility, needsDevEval
: 154389 161011 (view as bug list)
Depends on:
Blocks: Shortcuts-Accelerators
  Show dependency treegraph
 
Reported: 2022-03-04 10:44 UTC by Heiko Tietze
Modified: 2024-07-05 10:58 UTC (History)
7 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
Comment 3 Heiko Tietze 2024-07-05 06:37:26 UTC
*** Bug 161011 has been marked as a duplicate of this bug. ***
Comment 4 Heiko Tietze 2024-07-05 06:37:45 UTC
*** Bug 154389 has been marked as a duplicate of this bug. ***
Comment 5 Heiko Tietze 2024-07-05 07:34:58 UTC
Hossein, how about making this an easyhack? 

MnemonicGenerator::CreateMnemonic() iterates somehow over the string and fails in case of Calc Data > Statistics (and other). The solution is probably a one-liner but to figure out the right place a bit tricky due to CJK.