Skip to content

Commit aa9ce85

Browse files
MrJulmaxkatz6
authored andcommitted
[macOS] Prevent popups from stealing focus (#17794)
1 parent f29675d commit aa9ce85

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

native/Avalonia.Native/src/OSX/PopupImpl.mm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ virtual HRESULT Show(bool activate, bool isDialog) override
4242

4343
return WindowBaseImpl::Show(activate, true);
4444
}
45+
46+
virtual bool ShouldTakeFocusOnShow() override
47+
{
48+
// Don't steal the focus from another windows if our parent is inactive
49+
if (Parent != nullptr && Parent->Window != nullptr && ![Parent->Window isKeyWindow])
50+
return false;
51+
52+
return WindowBaseImpl::ShouldTakeFocusOnShow();
53+
}
4554
};
4655

4756

0 commit comments

Comments
 (0)