Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

[Mac] Enforce NSAccessible window focus #904

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion Xwt.XamMac/Xwt.Mac/DialogBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ public void EndLoop ()
OrderOut (this);
Close();
NSApplication.SharedApplication.StopModal ();
if (parent != null)
if (parent != null) {
parent.MakeKeyAndOrderFront (parent);
NSApplication.SharedApplication.AccessibilityFocusedWindow = parent;
parent.AccessibilityFocused = true;
}
}

#endregion
Expand Down
4 changes: 4 additions & 0 deletions Xwt.XamMac/Xwt.Mac/WindowBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ internal void InternalShow ()
if (!ParentWindow.ChildWindows.Contains(this))
ParentWindow.AddChildWindow(this, NSWindowOrderingMode.Above);

ParentWindow.AccessibilityFocused = false;
NSApplication.SharedApplication.AccessibilityFocusedWindow = this;
AccessibilityFocused = true;

// always use NSWindow for alignment when running in guest mode and
// don't rely on AddChildWindow to position the window correctly
if (frontend.InitialLocation == WindowLocation.CenterParent && !(ParentWindow is WindowBackend))
Expand Down