Android: Hide text handle when it is out or covered

The text handle should not be visible in case when it is out of
the text-object, or when it is hidden by other object. That is why we
should call updateSelectionHandles() method after touch only in case
when cursor position fits to clipped input item rectangle.

Fixes: QTBUG-115005
Pick-to: 6.5
Change-Id: I35c083acd8fd4d5240e3bb15afa1afbec4ea0b26
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit d10d76f9f20d48d69117d9f7dab089cb2a696b2e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2023-10-18 21:40:08 +02:00 committed by Qt Cherry-pick Bot
parent 68ac8bdea3
commit bad32e1f06

View File

@ -769,7 +769,15 @@ void QAndroidInputContext::touchDown(int x, int y)
focusObjectStopComposing();
}
updateSelectionHandles();
// Check if cursor is visible in focused window before updating handles
QPlatformWindow *window = qGuiApp->focusWindow()->handle();
const QRectF curRect = cursorRectangle();
const QPoint cursorGlobalPoint = window->mapToGlobal(QPoint(curRect.x(), curRect.y()));
const QRect windowRect = QPlatformInputContext::inputItemClipRectangle().toRect();
const QRect windowGlobalRect = QRect(window->mapToGlobal(windowRect.topLeft()), windowRect.size());
if (windowGlobalRect.contains(cursorGlobalPoint.x(), cursorGlobalPoint.y()))
updateSelectionHandles();
}
}