Merge pull request #3217 from martinvanzijl/issue-1262-keep-textbox-focus-option

Keep focus on textboxes when moving mouse to another panel
This commit is contained in:
Rodney 2020-04-08 14:47:21 -05:00 committed by GitHub
commit 26a71f646a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View file

@ -32,6 +32,7 @@
#include <assert.h> #include <assert.h>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QDialog> #include <QDialog>
#include <QLineEdit>
extern TEnv::StringVar EnvSafeAreaName; extern TEnv::StringVar EnvSafeAreaName;
@ -127,7 +128,21 @@ void TPanel::enterEvent(QEvent *event) {
// Only when Toonz application is active // Only when Toonz application is active
QWidget *w = qApp->activeWindow(); QWidget *w = qApp->activeWindow();
if (w) { 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<QLineEdit *>(focusWidget);
if (lineEdit) {
shouldSetFocus = false;
}
}
if (shouldSetFocus) {
widgetFocusOnEnter();
}
// Some panels (e.g. Viewer, StudioPalette, Palette, ColorModel) are // Some panels (e.g. Viewer, StudioPalette, Palette, ColorModel) are
// activated when mouse enters. Viewer is activatable only when being // activated when mouse enters. Viewer is activatable only when being
// docked. // docked.

View file

@ -440,7 +440,21 @@ void SceneViewer::onEnter() {
tool->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<QLineEdit *>(focusWidget);
if (lineEdit) {
shouldSetFocus = false;
}
}
if (shouldSetFocus) {
setFocus();
}
update(); update();
} }