From 41079e14395369a647336be0c49f1a125fa5f1a5 Mon Sep 17 00:00:00 2001 From: Curtis Wensley Date: Fri, 15 Sep 2023 15:43:22 -0700 Subject: [PATCH] Mac: Fix reparenting a Form after hiding then setting back to visible --- src/Eto.Mac/Forms/FormHandler.cs | 5 +++++ src/Eto.Mac/Forms/MacWindow.cs | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Eto.Mac/Forms/FormHandler.cs b/src/Eto.Mac/Forms/FormHandler.cs index 6430494f2..6cb70e4bb 100644 --- a/src/Eto.Mac/Forms/FormHandler.cs +++ b/src/Eto.Mac/Forms/FormHandler.cs @@ -92,10 +92,15 @@ public override bool Visible { Control.OrderFront(ApplicationHandler.Instance.AppDelegate); FireOnShown(); + EnsureOwner(); } } else + { base.Visible = value; + if (value) + EnsureOwner(); + } } } diff --git a/src/Eto.Mac/Forms/MacWindow.cs b/src/Eto.Mac/Forms/MacWindow.cs index 2bd8fbb26..dec36cc8f 100644 --- a/src/Eto.Mac/Forms/MacWindow.cs +++ b/src/Eto.Mac/Forms/MacWindow.cs @@ -1286,6 +1286,10 @@ bool InternalSetOwner(Window owner) bool result = false; if (SetAsChildWindow && Widget.Loaded) { + // ensure we don't double subscribe to this event + // since this can get called multiple times + Widget.GotFocus -= HandleGotFocusAsChild; + if (owner != null) { var macWindow = owner.Handler as IMacWindow; @@ -1299,7 +1303,6 @@ bool InternalSetOwner(Window owner) } else { - Widget.GotFocus -= HandleGotFocusAsChild; var parentWindow = Control.ParentWindow; if (parentWindow != null) parentWindow.RemoveChildWindow(Control);