From 39a3c50f6f3d3aff52853510543388638a2524d5 Mon Sep 17 00:00:00 2001 From: Jarkko Koivikko Date: Thu, 13 Feb 2020 08:51:05 +0200 Subject: Fix the long press function on the symbol mode key v3 - Symbol mode key has a function which allows to select a symbol from symbol page by long press of the key and moving the finger to a key on the symbol page. However, if the finger was not moved away from the symbol key, it simulated a click on the symbol key, causing it to switch back to main layout. The simulated click is is needed for the function keys to allow switching between multiple pages (e.g. the 1/2 key) of symbols without lifting the finger. - Fix this bug by not simulating the click on the symbols key. - v2: Fix null pointer reference (QML) - v3: Do not switch to main layout in case of long press and release of the symbol mode key. Also, do not activate drag symbol mode if already in symbol mode. Task-number: QTBUG-77753 Change-Id: I4543f6ddf532d5b25c237aaeb188404eb9a7bd56 Reviewed-by: Jarkko Koivikko Reviewed-by: Mitch Curtis --- .../content/components/Keyboard.qml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/virtualkeyboard/content/components/Keyboard.qml b/src/virtualkeyboard/content/components/Keyboard.qml index 347f1076..954c6f2f 100644 --- a/src/virtualkeyboard/content/components/Keyboard.qml +++ b/src/virtualkeyboard/content/components/Keyboard.qml @@ -493,7 +493,7 @@ Item { InputContext.inputEngine.virtualKeyCancel() keyboardInputArea.initialKey = null alternativeKeys.openedByNavigationKeyLongPress = keyboard.navigationModeActive - } else if (keyboard.activeKey.key === Qt.Key_Context1) { + } else if (keyboard.activeKey.key === Qt.Key_Context1 && !keyboard.symbolMode) { InputContext.inputEngine.virtualKeyCancel() keyboardInputArea.dragSymbolMode = true keyboard.symbolMode = true @@ -1078,14 +1078,28 @@ Item { InputContext.inputEngine.virtualKeyCancel() setActiveKey(key) press(key, false) - if (dragSymbolMode) - pressAndHoldTimer.restart() + if (dragSymbolMode) { + if (key && key.functionKey && key.key !== Qt.Key_Context1) + pressAndHoldTimer.restart() + else + pressAndHoldTimer.stop() + } } } } onReleased: { - if (containsPoint(touchPoints, activeTouchPoint)) + if (containsPoint(touchPoints, activeTouchPoint)) { + if (dragSymbolMode) { + var key = keyOnPoint(activeTouchPoint.x, activeTouchPoint.y) + if (key && key.key === Qt.Key_Context1) { + dragSymbolMode = false + InputContext.inputEngine.virtualKeyCancel() + reset() + return + } + } releaseActiveKey(); + } } onCanceled: { if (containsPoint(touchPoints, activeTouchPoint)) -- cgit v1.2.3