Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14.2, 5.15.1
-
None
Description
The smallest but reproducible example is attached but I guess that everything boils down to ScrollView/TextArea size manipulations by RowLayout:
import QtQml 2.15 import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 ApplicationWindow { title: qsTr("qtbug1-demo") visible: true Connections { target: Qt.inputMethod function onKeyboardRectangleChanged() { var newRect = Qt.inputMethod.keyboardRectangle; console.log( "Qt.inputMethod::onKeyboardRectangleChanged" + " x: " + newRect.x + " y: " + newRect.y + " width: " + newRect.width + " height: " + newRect.height ); } } ColumnLayout { id: layout anchors.fill: parent ListView { id: listView Layout.fillWidth: true Layout.fillHeight: true model: 1000 delegate: Label { text: index } onMovementStarted: { if (!activeFocus) { focus = true; } } } Pane { id: inputPane Layout.fillWidth: true RowLayout { id: rowLayout width: parent.width spacing: 2 ScrollView { id: scrollView Layout.fillWidth: true Layout.maximumHeight: Screen.desktopAvailableHeight / 4 Layout.preferredHeight: textArea.implicitHeight Layout.alignment: Qt.AlignVCenter ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ScrollBar.horizontal.interactive: false onHeightChanged: { console.log("scrollView.RowLayout::onHeightChanged", height); /// @hack -> need to set position _before_ the middle of the text /* if (textArea.length > 0 && textArea.cursorPosition == textArea.length) { textArea.cursorPosition = 0; } */ } TextArea { id: textArea verticalAlignment: TextEdit.AlignTop wrapMode: TextArea.Wrap background: null } background: Rectangle { border.color: "red" border.width: 1 } } } } } }
0) Copy large enough text to the clipboard
1) Tap on the TextArea (remember the y values)
- Keyboard is visible
- Whole view is lifted up by keyboard
- Qt.inputMethod::onKeyboardRectangleChanged x: 0 *y: 647* width: 375 height: 216
- Qt.inputMethod::onKeyboardRectangleChanged x: 0 *y: 907* width: 375 height: 216
- Qt.inputMethod::onKeyboardRectangleChanged x: 0 *y: 647* width: 375 height: 260
2) Long press and wait for the system context menu with 'paste-suggestion'
3) Tap paste
- Keyboard is visible
- Whole view is lifted down
- TextArea is visually blocked by keyboard
- TextArea has active focus
- Qt.inputMethod::onKeyboardRectangleChanged x: 0 y: 387 width: 375 height: 260
Hack #1
After third stage type any letter to the TextArea from virtual keyboard - whole view is lifted up again immediately.
Hack #2
Reset cursor position when scrollView height is changed
onHeightChanged: { textArea.cursorPosition = 0; }
Observation #1 (iOS specific)
Implement @implementation iOSKeyboardListener : UIGestureRecognizer <UIGestureRecognizerDelegate> and observe: UIKeyboardWillShowNotification, UIKeyboardDidShowNotification, UIKeyboardWillHideNotification, UIKeyboardDidHideNotification, UIKeyboardDidChangeFrameNotification
Nothing from this list is happening on the third stage which means that keyboardRectangle calculated independently in qiosinputcontext.mm