Browse Source

Post NSAccessibility notifications for property changes on macOS (#21074)

pull/21083/head
Jumar Macato 4 months ago
committed by GitHub
parent
commit
b69e05eb28
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      native/Avalonia.Native/src/OSX/AvnWindow.mm
  2. 28
      native/Avalonia.Native/src/OSX/automation.mm
  3. 5
      src/Avalonia.Native/AvnAutomationPeer.cs
  4. 5
      src/Avalonia.Native/avn.idl

12
native/Avalonia.Native/src/OSX/AvnWindow.mm

@ -656,6 +656,18 @@
- (void)raisePropertyChanged:(AvnAutomationProperty)property
{
switch (property)
{
case AutomationPeer_Name:
NSAccessibilityPostNotification(self, NSAccessibilityTitleChangedNotification);
break;
case AutomationPeer_BoundingRectangle:
NSAccessibilityPostNotification(self, NSAccessibilityMovedNotification);
NSAccessibilityPostNotification(self, NSAccessibilityResizedNotification);
break;
default:
break;
}
}
@end

28
native/Avalonia.Native/src/OSX/automation.mm

@ -488,8 +488,32 @@
- (void)raisePropertyChanged:(AvnAutomationProperty)property
{
if (property == AutomationPeer_Name && _peer->GetLiveSetting() != LiveSettingOff)
[self raiseLiveRegionChanged];
switch (property)
{
case AutomationPeer_Name:
NSAccessibilityPostNotification(self, NSAccessibilityTitleChangedNotification);
if (_peer->GetLiveSetting() != LiveSettingOff)
[self raiseLiveRegionChanged];
break;
case ValueProvider_Value:
case RangeValueProvider_Value:
NSAccessibilityPostNotification(self, NSAccessibilityValueChangedNotification);
break;
case AutomationPeer_BoundingRectangle:
NSAccessibilityPostNotification(self, NSAccessibilityMovedNotification);
NSAccessibilityPostNotification(self, NSAccessibilityResizedNotification);
break;
case SelectionItemProvider_IsSelected:
case SelectionProvider_Selection:
NSAccessibilityPostNotification(self, NSAccessibilitySelectedChildrenChangedNotification);
break;
case ToggleProvider_ToggleState:
case ExpandCollapseProvider_ExpandCollapseState:
NSAccessibilityPostNotification(self, NSAccessibilityValueChangedNotification);
break;
default:
break;
}
}
- (void)raiseLiveRegionChanged

5
src/Avalonia.Native/AvnAutomationPeer.cs

@ -19,6 +19,11 @@ namespace Avalonia.Native
{ AutomationElementIdentifiers.ClassNameProperty, AvnAutomationProperty.AutomationPeer_ClassName },
{ AutomationElementIdentifiers.NameProperty, AvnAutomationProperty.AutomationPeer_Name },
{ RangeValuePatternIdentifiers.ValueProperty, AvnAutomationProperty.RangeValueProvider_Value },
{ ValuePatternIdentifiers.ValueProperty, AvnAutomationProperty.ValueProvider_Value },
{ TogglePatternIdentifiers.ToggleStateProperty, AvnAutomationProperty.ToggleProvider_ToggleState },
{ ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, AvnAutomationProperty.ExpandCollapseProvider_ExpandCollapseState },
{ SelectionItemPatternIdentifiers.IsSelectedProperty, AvnAutomationProperty.SelectionItemProvider_IsSelected },
{ SelectionPatternIdentifiers.SelectionProperty, AvnAutomationProperty.SelectionProvider_Selection },
};
private static readonly ConditionalWeakTable<AutomationPeer, AvnAutomationPeer> s_wrappers = new();

5
src/Avalonia.Native/avn.idl

@ -403,6 +403,11 @@ enum AvnAutomationProperty
AutomationPeer_ClassName,
AutomationPeer_Name,
RangeValueProvider_Value,
ValueProvider_Value,
ToggleProvider_ToggleState,
ExpandCollapseProvider_ExpandCollapseState,
SelectionItemProvider_IsSelected,
SelectionProvider_Selection,
}
struct AvnSize

Loading…
Cancel
Save