Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion native/Avalonia.Native/src/OSX/automation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ - (NSAccessibilityRole)accessibilityRole
case AutomationExpander: return NSAccessibilityDisclosureTriangleRole;
// Treat unknown roles as generic group container items. Returning
// NSAccessibilityUnknownRole is also possible but makes the screen
// reader focus on the item instead of passing focus to child items.
// reader focus on the item instead of passing focus to child items.
default: return NSAccessibilityGroupRole;
}
}
Expand Down Expand Up @@ -191,6 +191,7 @@ - (id)accessibilityAttributeValue:(NSAccessibilityAttributeName)attribute
{
switch (_peer->GetLiveSetting())
{
case LiveSettingOff: return nil;
case LiveSettingPolite: return @"polite";
case LiveSettingAssertive: return @"assertive";
}
Expand Down Expand Up @@ -519,6 +520,35 @@ - (void)raisePropertyChanged:(AvnAutomationProperty)property
- (void)raiseLiveRegionChanged
{
NSAccessibilityPostNotification(self, @"AXLiveRegionChanged" /* kAXLiveRegionChangedNotification */);

// Announce the new string
auto name = _peer->GetName();
if (name != nullptr)
{
NSAccessibilityPriorityLevel priority = NSAccessibilityPriorityLow;
switch (_peer->GetLiveSetting())
{
case LiveSettingOff:
return;
case LiveSettingPolite:
priority = NSAccessibilityPriorityMedium;
break;
case LiveSettingAssertive:
priority = NSAccessibilityPriorityHigh;
break;
}

NSDictionary <NSString *, id> *userInfo = @{
NSAccessibilityAnnouncementKey: GetNSStringAndRelease(name),
NSAccessibilityPriorityKey: @(priority)
};

id topLevel = [self accessibilityTopLevelUIElement];
if ([topLevel isKindOfClass:[AvnWindow class]])
{
NSAccessibilityPostNotificationWithUserInfo(topLevel, NSAccessibilityAnnouncementRequestedNotification, userInfo);
}
}
}

- (void)setAccessibilityFocused:(BOOL)accessibilityFocused
Expand Down