Browse Source

Add macOS AX BringIntoView/AXScrollArea Role (#21457)

pull/21486/head
Jumar Macato 4 months ago
committed by GitHub
parent
commit
980d8792c6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 22
      native/Avalonia.Native/src/OSX/automation.mm
  2. 2
      src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs
  3. 2
      src/Avalonia.Controls/Automation/Peers/ScrollViewerAutomationPeer.cs
  4. 2
      src/Avalonia.FreeDesktop.AtSpi/AtSpiNode.RoleMapping.cs
  5. 1
      src/Avalonia.Native/AvnAutomationPeer.cs
  6. 2
      src/Avalonia.Native/avn.idl
  7. 1
      src/Windows/Avalonia.Win32.Automation/AutomationNode.cs

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

@ -86,7 +86,7 @@
- (NSAccessibilityRole)accessibilityRole - (NSAccessibilityRole)accessibilityRole
{ {
auto controlType = _peer->GetAutomationControlType(); auto controlType = _peer->GetAutomationControlType();
switch (controlType) { switch (controlType) {
case AutomationButton: return NSAccessibilityButtonRole; case AutomationButton: return NSAccessibilityButtonRole;
case AutomationCalendar: return NSAccessibilityGridRole; case AutomationCalendar: return NSAccessibilityGridRole;
@ -123,6 +123,7 @@
case AutomationSplitButton: return NSAccessibilityPopUpButtonRole; case AutomationSplitButton: return NSAccessibilityPopUpButtonRole;
case AutomationWindow: return NSAccessibilityWindowRole; case AutomationWindow: return NSAccessibilityWindowRole;
case AutomationPane: return NSAccessibilityGroupRole; case AutomationPane: return NSAccessibilityGroupRole;
case AutomationScrollViewer: return NSAccessibilityScrollAreaRole;
case AutomationHeader: return @"AXHeading"; case AutomationHeader: return @"AXHeading";
case AutomationHeaderItem: return NSAccessibilityButtonRole; case AutomationHeaderItem: return NSAccessibilityButtonRole;
case AutomationTable: return NSAccessibilityTableRole; case AutomationTable: return NSAccessibilityTableRole;
@ -418,6 +419,25 @@
return YES; return YES;
} }
- (NSArray<NSAccessibilityActionName> *)accessibilityActionNames
{
NSAccessibilityActionName scrollToVisible = @"AXScrollToVisible";
NSArray<NSAccessibilityActionName> *base = [super accessibilityActionNames];
if (base == nil)
base = @[];
if ([base containsObject:scrollToVisible])
return base;
return [base arrayByAddingObject:scrollToVisible];
}
- (void)accessibilityPerformAction:(NSAccessibilityActionName)action
{
if ([action isEqualToString:@"AXScrollToVisible"])
_peer->BringIntoView();
else
[super accessibilityPerformAction:action];
}
- (BOOL)isAccessibilitySelected - (BOOL)isAccessibilitySelected
{ {
if (_peer->IsSelectionItemProvider()) if (_peer->IsSelectionItemProvider())

2
src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs

@ -49,6 +49,7 @@ namespace Avalonia.Automation.Peers
TitleBar, TitleBar,
Separator, Separator,
Expander, Expander,
ScrollViewer,
} }
public enum AutomationLandmarkType public enum AutomationLandmarkType
@ -609,6 +610,7 @@ namespace Avalonia.Automation.Peers
AutomationControlType.HeaderItem => "header item", AutomationControlType.HeaderItem => "header item",
AutomationControlType.TitleBar => "title bar", AutomationControlType.TitleBar => "title bar",
AutomationControlType.Expander => "group", AutomationControlType.Expander => "group",
AutomationControlType.ScrollViewer => "scroll viewer",
AutomationControlType.None => (GetLandmarkType()?.ToString() ?? controlType.ToString()).ToLowerInvariant(), AutomationControlType.None => (GetLandmarkType()?.ToString() ?? controlType.ToString()).ToLowerInvariant(),
_ => controlType.ToString().ToLowerInvariant(), _ => controlType.ToString().ToLowerInvariant(),
}; };

2
src/Avalonia.Controls/Automation/Peers/ScrollViewerAutomationPeer.cs

@ -66,7 +66,7 @@ namespace Avalonia.Automation.Peers
protected override AutomationControlType GetAutomationControlTypeCore() protected override AutomationControlType GetAutomationControlTypeCore()
{ {
return AutomationControlType.Pane; return AutomationControlType.ScrollViewer;
} }
protected override bool IsContentElementCore() => false; protected override bool IsContentElementCore() => false;

2
src/Avalonia.FreeDesktop.AtSpi/AtSpiNode.RoleMapping.cs

@ -53,6 +53,7 @@ namespace Avalonia.FreeDesktop.AtSpi
AutomationControlType.TitleBar => AtSpiRole.TitleBar, AutomationControlType.TitleBar => AtSpiRole.TitleBar,
AutomationControlType.Separator => AtSpiRole.Separator, AutomationControlType.Separator => AtSpiRole.Separator,
AutomationControlType.Expander => AtSpiRole.Panel, AutomationControlType.Expander => AtSpiRole.Panel,
AutomationControlType.ScrollViewer => AtSpiRole.ScrollPane,
_ => AtSpiRole.Unknown, _ => AtSpiRole.Unknown,
}; };
} }
@ -78,6 +79,7 @@ namespace Avalonia.FreeDesktop.AtSpi
AtSpiRole.ProgressBar => "progress bar", AtSpiRole.ProgressBar => "progress bar",
AtSpiRole.RadioButton => "radio button", AtSpiRole.RadioButton => "radio button",
AtSpiRole.ScrollBar => "scroll bar", AtSpiRole.ScrollBar => "scroll bar",
AtSpiRole.ScrollPane => "scroll pane",
AtSpiRole.Slider => "slider", AtSpiRole.Slider => "slider",
AtSpiRole.SpinButton => "spin button", AtSpiRole.SpinButton => "spin button",
AtSpiRole.StatusBar => "status bar", AtSpiRole.StatusBar => "status bar",

1
src/Avalonia.Native/AvnAutomationPeer.cs

@ -66,6 +66,7 @@ namespace Avalonia.Native
public int IsKeyboardFocusable() => _inner.IsKeyboardFocusable().AsComBool(); public int IsKeyboardFocusable() => _inner.IsKeyboardFocusable().AsComBool();
public void SetFocus() => _inner.SetFocus(); public void SetFocus() => _inner.SetFocus();
public int ShowContextMenu() => _inner.ShowContextMenu().AsComBool(); public int ShowContextMenu() => _inner.ShowContextMenu().AsComBool();
public void BringIntoView() => _inner.BringIntoView();
public void SetNode(IAvnAutomationNode node) public void SetNode(IAvnAutomationNode node)
{ {

2
src/Avalonia.Native/avn.idl

@ -650,6 +650,7 @@ enum AvnAutomationControlType
AutomationTitleBar, AutomationTitleBar,
AutomationSeparator, AutomationSeparator,
AutomationExpander, AutomationExpander,
AutomationScrollViewer,
} }
enum AvnLandmarkType enum AvnLandmarkType
@ -1281,6 +1282,7 @@ interface IAvnAutomationPeer : IUnknown
bool IsKeyboardFocusable(); bool IsKeyboardFocusable();
void SetFocus(); void SetFocus();
bool ShowContextMenu(); bool ShowContextMenu();
void BringIntoView();
IAvnAutomationPeer* GetRootPeer(); IAvnAutomationPeer* GetRootPeer();

1
src/Windows/Avalonia.Win32.Automation/AutomationNode.cs

@ -373,6 +373,7 @@ namespace Avalonia.Win32.Automation
AutomationControlType.TitleBar => UiaControlTypeId.TitleBar, AutomationControlType.TitleBar => UiaControlTypeId.TitleBar,
AutomationControlType.Separator => UiaControlTypeId.Separator, AutomationControlType.Separator => UiaControlTypeId.Separator,
AutomationControlType.Expander => UiaControlTypeId.Group, AutomationControlType.Expander => UiaControlTypeId.Group,
AutomationControlType.ScrollViewer => UiaControlTypeId.Pane,
_ => UiaControlTypeId.Custom, _ => UiaControlTypeId.Custom,
}; };
} }

Loading…
Cancel
Save