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