From 7400e7099c475d728bb16a2421669c3575f65195 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 4 Sep 2020 08:58:29 -0700 Subject: [PATCH] Fixed focus issue with popup error --- IDE/src/IDEApp.bf | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index c8a5c899..effff7a7 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -4465,8 +4465,26 @@ namespace IDE ShowTab(panel, label, false, setFocus); if (setFocus) panel.FocusForKeyboard(); + if ((!panel.mWidgetWindow.mHasFocus) && (!mRunningTestScript)) - panel.mWidgetWindow.SetForeground(); + { + bool hasFocus = false; + BFWindow activeWindow = GetActiveWindow(true); + BFWindow checkWindow = activeWindow; + while (checkWindow != null) + { + if (checkWindow == panel.mWidgetWindow) + { + activeWindow.SetForeground(); + hasFocus = true; + break; + } + checkWindow = checkWindow.mParent; + } + + if (!hasFocus) + panel.mWidgetWindow.SetForeground(); + } #endif } @@ -5480,13 +5498,13 @@ namespace IDE return null; } - public WidgetWindow GetActiveWindow() + public WidgetWindow GetActiveWindow(bool allowModal = false) { for (let window in mWindows) if (window.mHasFocus) { var result = window; - while ((result.mWindowFlags.HasFlag(.Modal)) && (result.mParent != null)) + while ((result.mWindowFlags.HasFlag(.Modal)) && (result.mParent != null) && (!allowModal)) result = result.mParent; return result as WidgetWindow; }