Skip to content

Commit

Permalink
Add MSAA focus event on ComboBox dropdown close (#8220)
Browse files Browse the repository at this point in the history
* Add MSAA focus event on ComboBox dropdown close

Fixes #8218
This event lets NVDA correctly switch focus from dropdown to ComboBox edit field when dropdown is closed. NVDA recognizes ComboBox as IAccessible object, therefore it ignores existing UIA focus events.

* Improve comment with explanation of childID value

Co-authored-by: Tanya Solyanik <[email protected]>

Co-authored-by: Tanya Solyanik <[email protected]>
  • Loading branch information
Dmitrii Drobotov and Tanya-Solyanik authored Nov 17, 2022
1 parent 2a92763 commit 572929b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/System.Windows.Forms/src/System/Windows/Forms/ComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3058,6 +3058,11 @@ protected virtual void OnDropDownClosed(EventArgs e)
AccessibilityObject.RaiseAutomationEvent(UiaCore.UIA.AutomationFocusChangedEventId);
}

// Some accessibility tools (e.g., NVDA) could recognize ComboBox as IAccessible object
// and ignore UIA focus change event. For such cases we need to additionaly raise MSAA focus event.
// childID = CHILDID_SELF - 1 (the -1 will resolve to CHILDID_SELF when we call NotifyWinEvent)
AccessibilityNotifyClients(AccessibleEvents.Focus, childID: -1);

// Notify Collapsed/expanded property change.
AccessibilityObject.RaiseAutomationPropertyChangedEvent(
UiaCore.UIA.ExpandCollapseExpandCollapseStatePropertyId,
Expand Down

0 comments on commit 572929b

Please sign in to comment.