Skip to content

Commit

Permalink
Mac: Fix reparenting a Form after hiding then setting back to visible
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Sep 15, 2023
1 parent a225a41 commit 41079e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Eto.Mac/Forms/FormHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ public override bool Visible
{
Control.OrderFront(ApplicationHandler.Instance.AppDelegate);
FireOnShown();
EnsureOwner();
}
}
else
{
base.Visible = value;
if (value)
EnsureOwner();
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/Eto.Mac/Forms/MacWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -1299,7 +1303,6 @@ bool InternalSetOwner(Window owner)
}
else
{
Widget.GotFocus -= HandleGotFocusAsChild;
var parentWindow = Control.ParentWindow;
if (parentWindow != null)
parentWindow.RemoveChildWindow(Control);
Expand Down

0 comments on commit 41079e1

Please sign in to comment.