diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs index c211df9aa32..ae5ed6ac5f1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs @@ -2364,7 +2364,8 @@ Windows.GtkWPFWidget GetFocusedWpfWidget () Gtk.Widget GetFocusedChild (Control widget) { Gtk.Container container; - + if (widget?.nativeWidget is AppKit.NSWindow window) + widget = Mac.GtkMacInterop.GetGtkWindow (window)?.Child; do { container = widget?.nativeWidget is Gtk.Container ? widget.GetNativeWidget () : null; if (container != null) { @@ -2376,7 +2377,7 @@ Gtk.Widget GetFocusedChild (Control widget) } } while (container != null); - return widget.nativeWidget is Gtk.Widget ? widget : null; + return widget?.nativeWidget is Gtk.Widget ? widget : null; } #if MAC