From a78469f6877467030011427a8066f1c76d01bbcd Mon Sep 17 00:00:00 2001 From: Curtis Wensley Date: Tue, 1 Feb 2022 09:30:53 -0800 Subject: [PATCH] Wpf: Fix calling Window.LostFocus when focus changes within a window --- src/Eto.Wpf/Forms/WpfWindow.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Eto.Wpf/Forms/WpfWindow.cs b/src/Eto.Wpf/Forms/WpfWindow.cs index 257dbbd266..bae4db526c 100644 --- a/src/Eto.Wpf/Forms/WpfWindow.cs +++ b/src/Eto.Wpf/Forms/WpfWindow.cs @@ -227,7 +227,11 @@ public override void AttachEvent(string id) Control.Activated += (sender, e) => Callback.OnGotFocus(Widget, EventArgs.Empty); break; case Eto.Forms.Control.LostFocusEvent: - Control.LostKeyboardFocus += (sender, e) => Callback.OnLostFocus(Widget, EventArgs.Empty); + // LostKeyboardFocus is called for every child, only fire event when the form is no longer active + Control.LostKeyboardFocus += (sender, e) => { + if (!Control.IsActive) + Callback.OnLostFocus(Widget, EventArgs.Empty); + }; break; case Window.LocationChangedEvent: Control.LocationChanged += (sender, e) => Callback.OnLocationChanged(Widget, EventArgs.Empty);