Skip to content

Bugfix: display ampersand character in the message of nvdaControls.MessageDialog#14607

Merged
seanbudd merged 1 commit into
nvaccess:masterfrom
CyrilleB79:addonDialogs
Mar 30, 2023
Merged

Bugfix: display ampersand character in the message of nvdaControls.MessageDialog#14607
seanbudd merged 1 commit into
nvaccess:masterfrom
CyrilleB79:addonDialogs

Conversation

@CyrilleB79

Copy link
Copy Markdown
Contributor

Link to issue number:

None

Summary of the issue:

When a message containing ampersand has to be displayed in nvdaControls.MessageDialog, the ampersand character is interpreted as an indication for accelerator key. Thus the ampersand character is not displayed and the following character is underlined.
Putting here an accelerator key does not make sense here since the wx.StaticText used in this dialog is not the label of a focusable element.

The real-life situation where this issue occurs is when installing NVDA Dev & Test Toolbox. The dialog indicates "Extension : NVDA Dev Test Toolbox 3.0" (without ampersand) instead of "Extension : NVDA Dev & Test Toolbox 3.0" (with ampersand).

Description of user facing changes

Messages displayed in nvdaControls.MessageDialog will be displayed correctly when the message contains ampersand character. E.g. add-on install dialog and add-on install errror dialogs will display correctly the name of add-ons containing ampersand character in their name.

Description of development approach

Doubled the ampersand character when present in the message.

Testing strategy:

Manual test:
Check that the issue is fixed when installing NVDA Dev & Test Toolbox.

Known issues with pull request:

I have made this PR minimalist, fixing only the situation where both these statements are true:

  • string used in a wx.StaticText can contain ampersand character.
  • the wx.StaticText is a standalone static text, i.e. not used as a label for another focusable element, e.g. edit field, combo-box or list following it

This PR is not waterproof to following hypothetical situations regarding standalone static text:

  • in the future, the string of a standalone static text is changed with an ampersan in NVDA codebase.
  • The string used in a standalone static text does not contain ampersand character but its translation does

For reviewer(s):
Maybe I should also handle these cases? In this PR? Or in another one? Or is it not worth it (assuming that translators do not use ampersand when it is not used in English)?
Let me know what you think.

Change log entries:

Not needed for such a small change.

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

@CyrilleB79 CyrilleB79 marked this pull request as ready for review February 2, 2023 14:05
@CyrilleB79 CyrilleB79 requested a review from a team as a code owner February 2, 2023 14:05
@CyrilleB79 CyrilleB79 requested a review from seanbudd February 2, 2023 14:05
@seanbudd

Copy link
Copy Markdown
Member

Rather than changing this on nvdaControls.MessageDialog, can you amend the messages directly?

@seanbudd seanbudd marked this pull request as draft February 15, 2023 23:54
@CyrilleB79

Copy link
Copy Markdown
Contributor Author

Rather than changing this on nvdaControls.MessageDialog, can you amend the messages directly?

Sorry, I am not sure to understand. Could you please be more specific? Could you indicate which message I should amend and where?

Also, in the initial description, I have written:

Putting here an accelerator key does not make sense here since the wx.StaticText used in this dialog is not the label of a focusable element.

If you disagree with this statement, could you explain why?

@CyrilleB79 CyrilleB79 marked this pull request as ready for review February 19, 2023 22:58
@seanbudd

Copy link
Copy Markdown
Member

I was hoping this could happen on the string injection side, rather than in MessageDialog, e.g. updating gui.addonGui,_showConfirmAddonInstallDialog to replace "&" with "&&" in the confirmInstallMessage.

Generally we expect inputs to be correct, rather than fixed by the dialog. One risk of this is strings that already escaped, e.g. "foo && bar", getting escaped again into "foo &&&& bar"

@CyrilleB79

Copy link
Copy Markdown
Contributor Author

I was hoping this could happen on the string injection side, rather than in MessageDialog, e.g. updating gui.addonGui,_showConfirmAddonInstallDialog to replace "&" with "&&" in the confirmInstallMessage.

That was my idea, before realizing that the issue was broader.

Generally we expect inputs to be correct, rather than fixed by the dialog. One risk of this is strings that already escaped, e.g. "foo && bar", getting escaped again into "foo &&&& bar"

Why do you consider that the "correct" input is a string where ampersand indicate an accelerator? The dialog is abstracted and from the point of view of a developer, the developer using this dialog does not need to know that the implementation uses a wx.StaticText, that the text of the message would be passed directly to wx.StaticText and thus that ampersands should be doubled.

On the contrary, I consider that there is no sense putting an accelerator in this string. It makes sense to use an accelerator only with objects that can perform actions or be focused, or wx.StaticText acting as labels for such objects. But in the present case, the wx.StaticText is not a label for another object but a message. Why would a developer using this dialog use an accelerator on this text object? Could you give an example?

Going further with a comparison

Note also the following test on standard Windows MessageBox (for an illustrating comparison only). In the Python console, type:

import winUser
winUser.MessageBox(0, 'Hello &world', 'Test', 0)

Visually, you can see that the message in the message box is "Hello &world" (with ampersand). Ampersand in the input string is not used to create an accelerator key.

Be careful to check visually and not with ATs since there is another issue, see below.

Additional issue with text reported in winUser.MessageBox

There is an additional issue with the text reported by winUser.MessageBox. This is beyond the work of this PR.

In the previous example:
winUser.MessageBox(0, 'Hello &world', 'Test', 0)
As written before, the text is visually "Hello aworld" (with ampersand). However the text reported by NVDA when object navigating to the message or when reading the whole dialog with NVDA+B is "Hello world" (without ampersand), and a possible shortcut key "alt+W" is reported. Pressing alt+W makes no action and a Windows error "ding" is heard, which IMO confirms that there is actually no shortcut. Note also that the Narrator also reports wrongly this shortcut key, which seems to points to an issue with how Windows presents things to ATs. The information on the object containing the message text indicates the following:

name: 'Hello world'
windowText: 'Hello &world'
displayText: 'Hello &world'
IAccessible accName: 'Hello world'

@seanbudd

Copy link
Copy Markdown
Member

This is a convincing argument.

@seanbudd seanbudd merged commit d6d37be into nvaccess:master Mar 30, 2023
@nvaccessAuto nvaccessAuto added this to the 2023.2 milestone Mar 30, 2023
seanbudd pushed a commit that referenced this pull request Jun 13, 2023
Issue similar to #14607.

Summary of the issue:
In the multi-category settings dialog, the panel takes the name of the corresponding category. This name is reported when tabbing from the category list to the panel. If the category name contains an ampersand, this character is not reported in the panel's name and it acts as an accelerator instead.

This is the case for NVDA Dev & Test Toolbox add-on where the add-on's name is used as category in the multi-category settings dialog and thus also as panel name.

Description of user facing changes
The panel's name will match the category name, even in the case this name contains an ampersand (&) character.

Description of development approach
Double the ampersand in the panel's name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants