Android: fix behovior of right click to not interfere with other clicks
To allow treating long press as right click on Android, set the environment variable QT_ANDROID_ENABLE_RIGHT_MOUSE_FROM_LONG_PRESS to 1. Pick-to: 5.15 Fixes: QTBUG-73416 Task-number: QTBUG-84179 Change-Id: Ibe1d6af6ab9965112f1418638a088717798b554c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
a7162704c8
commit
cde86464df
@ -202,7 +202,7 @@ namespace QtAndroidInput
|
|||||||
QMetaObject::invokeMethod(inputContext, "longPress", Q_ARG(int, x), Q_ARG(int, y));
|
QMetaObject::invokeMethod(inputContext, "longPress", Q_ARG(int, x), Q_ARG(int, y));
|
||||||
|
|
||||||
//### TODO: add proper API for Qt 5.2
|
//### TODO: add proper API for Qt 5.2
|
||||||
static bool rightMouseFromLongPress = qEnvironmentVariableIntValue("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS");
|
static bool rightMouseFromLongPress = qEnvironmentVariableIntValue("QT_ANDROID_ENABLE_RIGHT_MOUSE_FROM_LONG_PRESS");
|
||||||
if (!rightMouseFromLongPress)
|
if (!rightMouseFromLongPress)
|
||||||
return;
|
return;
|
||||||
m_ignoreMouseEvents = true;
|
m_ignoreMouseEvents = true;
|
||||||
@ -210,15 +210,15 @@ namespace QtAndroidInput
|
|||||||
QWindow *tlw = topLevelWindowAt(globalPos);
|
QWindow *tlw = topLevelWindowAt(globalPos);
|
||||||
QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;
|
QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;
|
||||||
|
|
||||||
// Release left button
|
// Click right button if no other button is already pressed.
|
||||||
QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos,
|
if (!m_mouseGrabber) {
|
||||||
Qt::MouseButtons(Qt::NoButton), Qt::LeftButton,
|
|
||||||
QEvent::MouseButtonRelease);
|
|
||||||
|
|
||||||
// Press right button
|
|
||||||
QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos,
|
QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos,
|
||||||
Qt::MouseButtons(Qt::RightButton), Qt::RightButton,
|
Qt::MouseButtons(Qt::RightButton), Qt::RightButton,
|
||||||
QEvent::MouseButtonPress);
|
QEvent::MouseButtonPress);
|
||||||
|
QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos,
|
||||||
|
Qt::MouseButtons(Qt::NoButton), Qt::RightButton,
|
||||||
|
QEvent::MouseButtonRelease);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void touchBegin(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/)
|
static void touchBegin(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user