Windows 11 emoji panel/navigation menu item: handle UIA elemenet selected event by ignoring it or manipulating NVDA's focus object (#16555)
Closes #16346
Closes #16532
Closes #16533
Follow-up to #16347
Summary of the issue:
NVDA cuts off speech, repeats items, and does not report system focus upon closing emji panel when handling element selected event in Windows 11 emoji panel's navigation menu items.
Description of user facing changes
NVDA will:
No longer cut off speech when reviewing kaomojis and symbols in fullscreen
Nl longer announce "clipboard history" twice when reviewing amoji panel categories
No longer get stuck in emoji panel items when the panel closes
Description of development approach
A dedicated overlay class was added for Windows 11 emoji panel navigation menu items along with UIA element selected event for them that does the following:
Ignores the event when the panel closes, system focus moves to menu items, and while kaomojis and symbols are shown on screen
Sets NVDA focus to system focus when emoji panel closes and NVDA finds itself stuck in emoji panel main window.
Testing strategy:
Manual testing: see #16346, #16532, and #16533. Specifically, test to make sure that NVDA is no longer announcing "clipboard history" twice while navigating parts of the emoji panel and speech is no longer cut off while reviewing kaomojis and symbols.
Commits:
* Modern keyboard: define an overlay class for Windows 11 emoji panel navigation menu item.
Define a dedicated overlay class for Windows 11 emoji panel navigation menu items (deriving from UIA list item class) to handle elemenet selected event and others if needed. This keeps the element selectd event handler defined in the app module simple.
* Emoji panel/choose overlay classes: recognize list items with Automation Id string staring with 'navigation-menu-item' as navigation menu item class.
Rework list item recognition: if encountering a list item, differentiate between IME candidate items and Windows 11 emoji panel navigation menu items.
* Emoji panel/UIA element selected: let navigation menu item overlay class handle the event.
Allow Windows 11 emoji panel navigation menu item overlay class to handle UIA element selected evnt in situations such as element selected event being fired when emoji panel closes in Windows 11.
* Windows 11 emoji panel/navigation menu item: ignore element selected event if the event fires when the emoji panel is closed. Re #16346.
Define UIA element selected event for navigation menu item overlay class, designed to ignore the event when conditions arise. The first condition is event being fired when closing the emoji panel - check the app modules and ignore the event if the focused app module is not the emoji panel app module, utilizing Python 3.8's assignment expression (:=) syntax (focus object is neeeded in other conditions).
* Windows 11 emoji panel/navigation menu item: report the selected menu item when apropriate. Re #16346.
Report the selected menu item when ignore conditions are dealt with.
* Windows 11 emoji panel/navigation menu item: manipulate focus when emoji panel is closed and emoji search field is offscreen. Re #16346.
Unlike the event ignore condition, NVDA's focus object stays on emoji edit field when the panel is closed, leaving it offscren. In this case, NVDA does not know where to move the 'focus object' to. Therefore, tell NVDA to queue gain focus event on the system focus control returned by obj.objectWithFocus() method.
* Winodws 11 emoji panel/navigation menu item: ignore element selected event if menu items are gaining focus. Re #16532.
Gain focus event is fired by navigation menu itmes if the panel is open to clipboard history, resulting in repetitions (both gain focus and element selected events are fired for clipboard history item). Ignore the element selected event so gain focus event can announce the selected menu item.
* Windows 11 emoji panel/navigation menu item: ignore the event when reviewing kaomojis and symbols in fullscreen. Re #16533.
Gain focus event is fired when moving through kaomoji and symbol entries. When Tab is pressed, both gain focus and elemenet selected events are fired. Therefore, trust the gain focus event.
* Windows 11 emoji panel/navigation menu item: move NVDA focus to system focus when emoji panel main window unexpected gains focus accompanied by elemenet selected event. Re #16347.
A variation of issue 16347: sometimes when closing emoji panel/clipboard history, input experience main window grabs NVDA's focus accompanied with UIA element selected event. The gain focus event handler defined at the app module level only manipulates focus if no events are pending, but inthis case, events were pending. Therefore, catch this and manipulate NVDA focus if NVDA finds itself stuck in emoji panel main window element while handling element selected event.
* Windows 11 emoji panel/overlay class chooser (Flake8): add missing colon.
* Changelog: add Windows 11 emoji panel navigation menu entries
* Changelog: clarity (suggested by Code Rabbit AI)
* Windows 11 emoji panel/navigation menu item: add type hint for element selected event handler