From 53bbb1b9c555c7207a5ff40aab59cd60304bb851 Mon Sep 17 00:00:00 2001 From: dimkanovikov Date: Sat, 25 Sep 2021 12:32:28 +0300 Subject: [PATCH] Fix issue with focusing text editor inside scalable wrapper --- .../text_edit/scalable_wrapper/scalable_wrapper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/corelib/ui/widgets/text_edit/scalable_wrapper/scalable_wrapper.cpp b/src/corelib/ui/widgets/text_edit/scalable_wrapper/scalable_wrapper.cpp index 74114d15b..17ee1bff0 100644 --- a/src/corelib/ui/widgets/text_edit/scalable_wrapper/scalable_wrapper.cpp +++ b/src/corelib/ui/widgets/text_edit/scalable_wrapper/scalable_wrapper.cpp @@ -227,15 +227,17 @@ bool ScalableWrapper::event(QEvent* _event) // Прочие стандартные обработчики событий // default: { - result = QGraphicsView::event(_event); // // Переустанавливаем фокус в редактор, иначе в нём пропадает курсор // if (_event->type() == QEvent::FocusIn) { - d->editor->clearFocus(); d->editor->setFocus(); - } else if (_event->type() == QEvent::FocusOut) { + } + + result = QGraphicsView::event(_event); + + if (_event->type() == QEvent::FocusOut) { d->editor->clearFocus(); } @@ -388,8 +390,7 @@ bool ScalableWrapper::eventFilter(QObject* _object, QEvent* _event) // // Возвращаем фокус редактору, если он его потерял // - if (_object == d->editor.data() && _event->type() == QEvent::FocusOut) { - d->editor->clearFocus(); + if (_object == d->editor.data() && _event->type() == QEvent::FocusOut && hasFocus()) { d->editor->setFocus(); }