QmlDesigner: Fix text selection bug for code editor

The event is returned to the parent hierarchy when the position is not
in the scrollbars area.

Task-number: QDS-9726
Change-Id: Id781650e15035a26f282990d7ee387b4417bc6eb
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Ali Kianian
2023-04-19 16:49:14 +03:00
parent 6035ff939d
commit ca300e9eb8

View File

@@ -41,24 +41,31 @@ public:
} }
} }
inline void checkToFlashScroll(QPointer<ScrollBar> scrollBar, const QPoint &pos) inline bool checkToFlashScroll(QPointer<ScrollBar> scrollBar, const QPoint &pos)
{ {
if (scrollBar.isNull()) if (scrollBar.isNull())
return; return false;
if (!scrollBar->style()->styleHint( if (!scrollBar->style()->styleHint(
QStyle::SH_ScrollBar_Transient, QStyle::SH_ScrollBar_Transient,
nullptr, scrollBar)) nullptr, scrollBar))
return; return false;
if (scrollBarRect(scrollBar).contains(pos)) if (scrollBarRect(scrollBar).contains(pos)) {
scrollBar->flash(); scrollBar->flash();
return true;
}
return false;
} }
inline void checkToFlashScroll(const QPoint &pos) inline bool checkToFlashScroll(const QPoint &pos)
{ {
checkToFlashScroll(verticalScrollBar, pos); bool coversScroll = checkToFlashScroll(verticalScrollBar, pos);
checkToFlashScroll(horizontalScrollBar, pos); if (!coversScroll)
coversScroll |= checkToFlashScroll(horizontalScrollBar, pos);
return coversScroll;
} }
inline void installViewPort(QObject *eventHandler) { inline void installViewPort(QObject *eventHandler) {
@@ -126,8 +133,8 @@ bool TransientScrollAreaSupport::eventFilter(QObject *watched, QEvent *event)
if (watched == d->viewPort){ if (watched == d->viewPort){
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent) { if (mouseEvent) {
d->checkToFlashScroll(mouseEvent->pos()); if (d->checkToFlashScroll(mouseEvent->pos()))
return true; return true;
} }
} }
} }