From 26a71f646a826806352f5468644a6b0764701f6a Mon Sep 17 00:00:00 2001 From: Rodney Date: Apr 08 2020 19:47:21 +0000 Subject: Merge pull request #3217 from martinvanzijl/issue-1262-keep-textbox-focus-option Keep focus on textboxes when moving mouse to another panel --- diff --git a/toonz/sources/toonz/pane.cpp b/toonz/sources/toonz/pane.cpp index 463ae26..a7eebeb 100644 --- a/toonz/sources/toonz/pane.cpp +++ b/toonz/sources/toonz/pane.cpp @@ -32,6 +32,7 @@ #include #include #include +#include extern TEnv::StringVar EnvSafeAreaName; @@ -127,7 +128,21 @@ void TPanel::enterEvent(QEvent *event) { // Only when Toonz application is active QWidget *w = qApp->activeWindow(); if (w) { - widgetFocusOnEnter(); + // grab the focus, unless a line-edit is focused currently + bool shouldSetFocus = true; + + QWidget *focusWidget = qApp->focusWidget(); + if (focusWidget) { + QLineEdit *lineEdit = dynamic_cast(focusWidget); + if (lineEdit) { + shouldSetFocus = false; + } + } + + if (shouldSetFocus) { + widgetFocusOnEnter(); + } + // Some panels (e.g. Viewer, StudioPalette, Palette, ColorModel) are // activated when mouse enters. Viewer is activatable only when being // docked. diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp index 1791a49..20cf63c 100644 --- a/toonz/sources/toonz/sceneviewerevents.cpp +++ b/toonz/sources/toonz/sceneviewerevents.cpp @@ -440,7 +440,21 @@ void SceneViewer::onEnter() { tool->onEnter(); } - setFocus(); + // grab the focus, unless a line-edit is focused currently + bool shouldSetFocus = true; + + QWidget *focusWidget = qApp->focusWidget(); + if (focusWidget) { + QLineEdit *lineEdit = dynamic_cast(focusWidget); + if (lineEdit) { + shouldSetFocus = false; + } + } + + if (shouldSetFocus) { + setFocus(); + } + update(); }