diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2021-01-19 10:33:05 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-01-22 09:20:04 +0000 |
commit | 72f3c9ff5ea7585c978bc8cedbf860a84b2cd397 (patch) | |
tree | 2f05fbf9d80a7923f2b5c0689837a61589ae9ba9 | |
parent | e3901f053fde1fc956da629efc358559970dbc43 (diff) |
Fix position of the keyboardRectangle in app integration
InputPanel contained double mapping of keyboardRectangle to QML
root. The problem was that inputPanel.x and y were already relative
to parent so mapToItem(null) doubled the value.
Use function to calculate the rectangle. This function also
references the position of the inputPanel, so it is properly
updated in the Binding.
Task-number: QTBUG-85554
Change-Id: Iaf5075f31f27bc08bbf41aa5960303705135cd16
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 40928827d166649afa1b256e7b05dcd11442d25a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/virtualkeyboard/content/InputPanel.qml | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/virtualkeyboard/content/InputPanel.qml b/src/virtualkeyboard/content/InputPanel.qml index 07ad3562..a0ebc8b3 100644 --- a/src/virtualkeyboard/content/InputPanel.qml +++ b/src/virtualkeyboard/content/InputPanel.qml @@ -126,6 +126,7 @@ Item { implicitHeight: keyboard.height Keyboard { id: keyboard + readonly property real yOffset: keyboard.wordCandidateView.currentYOffset - (keyboard.shadowInputControl.visible ? keyboard.shadowInputControl.height : 0) anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom @@ -139,12 +140,22 @@ Item { Binding { target: InputContext.priv property: "keyboardRectangle" - value: mapToItem(null, - desktopPanel ? keyboard.x : x, - (desktopPanel ? keyboard.y : y) + keyboard.wordCandidateView.currentYOffset - (keyboard.shadowInputControl.visible ? keyboard.shadowInputControl.height : 0), - keyboard.width, - keyboard.height - keyboard.wordCandidateView.currentYOffset + (keyboard.shadowInputControl.visible ? keyboard.shadowInputControl.height : 0)) + value: keyboardRectangle() when: !InputContext.animating restoreMode: Binding.RestoreBinding } + + /*! \internal */ + function keyboardRectangle() { + var rect = Qt.rect(0, keyboard.yOffset, keyboard.width, keyboard.height - keyboard.yOffset) + if (desktopPanel) { + rect.x += keyboard.x + rect.y += keyboard.y + } + // Read the inputPanel position. + // This ensures that the Binding works. + var unusedX = inputPanel.x + var unusedY = inputPanel.y + return mapToItem(null, rect) + } } |