Skip to content

Windows 11 Notepad: reposition status bar index to be the second to last item#14574

Merged
michaelDCurran merged 5 commits into
nvaccess:masterfrom
josephsl:i14573w11NotepadStatusBarRepositioning
Feb 9, 2023
Merged

Windows 11 Notepad: reposition status bar index to be the second to last item#14574
michaelDCurran merged 5 commits into
nvaccess:masterfrom
josephsl:i14573w11NotepadStatusBarRepositioning

Conversation

@josephsl

Copy link
Copy Markdown
Contributor

Link to issue number:

Fixes #14573

Summary of the issue:

Status bar contents are not read in Notepad 11.2212.

Description of user facing changes

Status bar will be read in newer Notepad 11 releases.

Description of development approach

Reposition status bar index to become second to last item (-2) in the Notepad UI tree. This is applicable in stable (11.2210 as of time of this pull request) and upcoming dev (11.2212) release with tabbed Notepad interface. Unless the UI tree changes significantly, this change will support old and new Windows 11 Notepad releases.

Testing strategy:

Manual testing:

  1. Prepare two Windows 11 systems: one running build 22621 and another running an Insider Preview dev build (such as 25281).
  2. Open Notepad on both versions, and for Insider Preview, make sure this is 11.2212 or later with tabbed Notepad interface.
  3. With Notepad open on both systems, retrieve the status bar (NVDA+End in desktop layout, NVDA+Shift+End in laptop layout).
  4. Verify that NVDA is announcing actual status bar content.

Known issues with pull request:

None

Change log entries:

Bug fixes (can be grouped under Windows 11 fixes or as a standalone entry):

In newer releases of Windows 11 Notepad, NVDA can once again announce status bar contents. (#14573)

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.

…cess#14573.

Upcoming Notepad version 11.2212 introduces tabbed interface, useful for opening multiple files in a single Notepad window. As a result, this changes the UI tree in that status bar entry position is no longer the eighth position. Thankfully, the status bar text is the second to last item in the Notepad UI tree across versions (stable and dev), so use -2 to represent status bar index.
@josephsl josephsl requested a review from a team as a code owner January 19, 2023 22:47
@josephsl josephsl requested a review from seanbudd January 19, 2023 22:47
@michaelDCurran michaelDCurran merged commit 2c33c27 into nvaccess:master Feb 9, 2023
@nvaccessAuto nvaccessAuto added this to the 2023.1 milestone Feb 9, 2023
@josephsl

josephsl commented Feb 9, 2023 via email

Copy link
Copy Markdown
Contributor Author

@michaelDCurran

Copy link
Copy Markdown
Member

@josephsl Sorry did not see your comment until after I merged. I have reverted in pr #14620

@josephsl

josephsl commented Feb 9, 2023 via email

Copy link
Copy Markdown
Contributor Author

josephsl added a commit to josephsl/nvda that referenced this pull request Feb 9, 2023
…etching status bar. Re nvaccess#14573.

nvaccess#14574 rework: Notepad 11.2301 introduces tabbed Notepad where multiple documents can be opened at once. This changes the Notepad UI tree so the old status bar chlid index no longer works. In the now reverted nvaccess#14574 pull request, a different status bar index was used, but it had a critical flaw: when Notepad settings (Alt+S) opens and then closes, status bar command will say something, caused by UI tree changing once again. A more robust solution is using UIA descendants to look for a specific element, and provided that the Automation Id for the first status bar text stays the same (ContentTextBlock), the descendants approach will work. This is the same approach used in File Explorer app module to obtain status bar contents in File Explorer.
seanbudd added a commit that referenced this pull request Mar 28, 2023
… app releases via UIA decendants (#14622)

Closes #14573
Take 2 on #14573
Resolves a flaw discovered in #14574

Summary of the issue:
In #14574 and earlier, NVDA relied on child index when retrieving Windows 11 Notepad status bar contents. This is flawed: there are times when UI tree in Notepad can change if something opens and then closes. Specifically, when Notepad settings window (Alt+S) is opened and then closed, NVDA will announce something else when retrieving status bar contents.

Description of user facing changes
NVDA will announce status bar contents in newer Windows 11 Notepad releases (same as #14574).

Description of development approach
Use UIA's FindFirstBuildCache to retrieve status bar contents (Automation Id: ContentTextBlock). As long as the Automation Id stays the same, the descendants approach will work across Notepad 11 releases.

---
commits:

* appModules/notepad: use UIA descendants instead of child index when fetching status bar. Re #14573.

#14574 rework: Notepad 11.2301 introduces tabbed Notepad where multiple documents can be opened at once. This changes the Notepad UI tree so the old status bar chlid index no longer works. In the now reverted #14574 pull request, a different status bar index was used, but it had a critical flaw: when Notepad settings (Alt+S) opens and then closes, status bar command will say something, caused by UI tree changing once again. A more robust solution is using UIA descendants to look for a specific element, and provided that the Automation Id for the first status bar text stays the same (ContentTextBlock), the descendants approach will work. This is the same approach used in File Explorer app module to obtain status bar contents in File Explorer.

* appModules/notepad: restore copyright header and type hints. Re #14573

* appModules/notepad: uiItemWindow -> notepadWindow

* appModules/notepad: status bar/UIA descendatns now resembles File Explorer app module more closely. Re #14573.

Inspired by status bar getter in File Explorer app module: because Notepad foreground window is not a UIA element, tell UIA handler to obtain UIA element from foreground window handle. Apart from this and checking for AutomationId, Notepad status bar getter resembles File Explorer app module.

* appModules/notepad: catch value error if the status bar content UIA element is NULL.

UIA element for status bar contents wil be NULL (0x0) if status bar is not showing, therefore catch value error that can result from it.

* appModules/notepad: remove status bar location check.

Since status bar UIA element is not defined if invisible, there is no need to check its location.

* appModules/notepad: UIAHandler.handler.clientObject -> clientObject

* update changes

---------

Co-authored-by: Sean Budd <sean@nvaccess.org>
@josephsl josephsl deleted the i14573w11NotepadStatusBarRepositioning branch March 31, 2023 15:19
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.

Windows 11 Notepad: status bar retrieval fails if Notepad UI is redesigned, specifically with tabbed Notepad

3 participants