Browse Source

Make automation to target FocusRoot

pull/20732/head
Nikita Tsukanov 4 weeks ago
parent
commit
263eeabbc5
  1. 4
      src/Avalonia.Base/Input/IInputRoot.cs
  2. 2
      src/Avalonia.Native/TopLevelImpl.cs
  3. 2
      src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

4
src/Avalonia.Base/Input/IInputRoot.cs

@ -30,6 +30,8 @@ namespace Avalonia.Input
// HACK: This is a temporary hack for "default focus" concept.
// If nothing is focused we send keyboard events to Window. Since for now we always
// control PresentationSource, we simply pass the TopLevel as a separate parameter there.
internal InputElement FocusRoot { get; }
// It's also currently used by automation since we have special WindowAutomationPeer which needs to target the
// window itself
public InputElement FocusRoot { get; }
}
}

2
src/Avalonia.Native/TopLevelImpl.cs

@ -169,7 +169,7 @@ internal class TopLevelImpl : ITopLevelImpl, IFramebufferPlatformSurface
public AutomationPeer? GetAutomationPeer()
{
return _inputRoot?.RootElement is Control c ? ControlAutomationPeer.CreatePeerForElement(c) : null;
return _inputRoot?.FocusRoot is Control c ? ControlAutomationPeer.CreatePeerForElement(c) : null;
}
public bool RawTextInputEvent(ulong timeStamp, string text)

2
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

@ -937,7 +937,7 @@ namespace Avalonia.Win32
return IntPtr.Zero;
}
case WindowsMessage.WM_GETOBJECT:
if ((long)lParam == uiaRootObjectId && UiaCoreTypesApi.IsNetComInteropAvailable && _owner?.RootElement is Control control)
if ((long)lParam == uiaRootObjectId && UiaCoreTypesApi.IsNetComInteropAvailable && _owner?.FocusRoot is Control control)
{
var peer = ControlAutomationPeer.CreatePeerForElement(control);
var node = AutomationNode.GetOrCreate(peer);

Loading…
Cancel
Save