Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix lineedit focus lost

shun-iwasawa3cf6a364327e
diff --git a/toonz/sources/toonz/pane.cpp b/toonz/sources/toonz/pane.cpp
index 3a22b8524..215266737 100644
--- a/toonz/sources/toonz/pane.cpp
+++ b/toonz/sources/toonz/pane.cpp
@@ -119,19 +119,13 @@ void TPanel::enterEvent(QEvent *event) {
QWidget *w = qApp->activeWindow();
if (w) {
// grab the focus, unless a line-edit is focused currently
- bool shouldSetFocus = true;
-
QWidget *focusWidget = qApp->focusWidget();
- if (focusWidget) {
- QLineEdit *lineEdit = dynamic_cast<QLineEdit *>(focusWidget);
- if (lineEdit) {
- shouldSetFocus = false;
- }
+ if (focusWidget && dynamic_cast<QLineEdit *>(focusWidget)) {
+ event->accept();
+ return;
}
- if (shouldSetFocus) {
- widgetFocusOnEnter();
- }
+ widgetFocusOnEnter();
// Some panels (e.g. Viewer, StudioPalette, Palette, ColorModel) are
// activated when mouse enters. Viewer is activatable only when being
@@ -147,7 +141,13 @@ void TPanel::enterEvent(QEvent *event) {
//-----------------------------------------------------------------------------
/*! clear focus when mouse leaves
*/
-void TPanel::leaveEvent(QEvent *event) { widgetClearFocusOnLeave(); }
+void TPanel::leaveEvent(QEvent *event) {
+ QWidget *focusWidget = qApp->focusWidget();
+ if (focusWidget && dynamic_cast<QLineEdit *>(focusWidget)) {
+ return;
+ }
+ widgetClearFocusOnLeave();
+}
//-----------------------------------------------------------------------------
/*! load and restore previous geometry and state of the floating panel.