on xenial help sign in
Move textarea up automatically when inputmethod popup.
b0a1c58Gary.Wzl
qml/Dash/Previews/Preview.qml+20−1
@@ -66,10 +66,25 @@ Item {
66 delegate: ListView {
66 delegate: ListView {
67 id: column
67 id: column
68 objectName: "previewListRow" + index
68 objectName: "previewListRow" + index
69+ anchors {
70+ top: parent.top
69− anchors { top: parent.top; bottom: parent.bottom }
71+ bottom: parent.bottom
72+ }
70 width: row.columnWidth
73 width: row.columnWidth
71 spacing: row.spacing
74 spacing: row.spacing
72 bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
75 bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
76+ property var makeSureVisibleItem
77+ property real previousVisibleHeight: 0
78+ property real visibleHeight: height - bottomMargin
79+ onVisibleHeightChanged: {
80+ if (makeSureVisibleItem && makeSureVisibleItem.activeFocus && previousVisibleHeight > visibleHeight) {
81+ var textAreaPos = makeSureVisibleItem.mapToItem(column, 0, 0);
82+ if (textAreaPos.y + makeSureVisibleItem.height > column.visibleHeight) {
83+ column.contentY += textAreaPos.y + makeSureVisibleItem.height - column.visibleHeight
84+ }
85+ }
86+ previousVisibleHeight = visibleHeight;
87+ }
73
88
74 model: columnModel
89 model: columnModel
75 cacheBuffer: height
90 cacheBuffer: height
@@ -92,6 +107,10 @@ Item {
92 onTriggered: {
107 onTriggered: {
93 previewModel.triggered(widgetId, actionId, data);
108 previewModel.triggered(widgetId, actionId, data);
94 }
109 }
110+ onMakeSureVisible: {
111+ column.previousVisibleHeight=column.visibleHeight
112+ column.makeSureVisibleItem=item
113+ }
95
114
96 onFocusChanged: if (focus) column.positionViewAtIndex(index, ListView.Contain)
115 onFocusChanged: if (focus) column.positionViewAtIndex(index, ListView.Contain)
97
116
qml/Dash/Previews/PreviewCommentInput.qml+7
@@ -38,6 +38,13 @@ PreviewWidget {
38 TextArea {
38 TextArea {
39 id: commentTextArea
39 id: commentTextArea
40 objectName: "commentTextArea"
40 objectName: "commentTextArea"
41+
42+ property bool inputMethodVisible: Qt.inputMethod.visible
43+ onInputMethodVisibleChanged: {
44+ if(inputMethodVisible && activeFocus)
45+ root.makeSureVisible(commentTextArea);
46+ }
47+
41 anchors {
48 anchors {
42 top: parent.top
49 top: parent.top
43 left: parent.left
50 left: parent.left
qml/Dash/Previews/PreviewExpandable.qml+3
@@ -96,6 +96,9 @@ PreviewWidget {
96 onTriggered: {
96 onTriggered: {
97 root.triggered(widgetId, actionId, data);
97 root.triggered(widgetId, actionId, data);
98 }
98 }
99+ onMakeSureVisible: {
100+ root.makeSureVisible(item)
101+ }
99 }
102 }
100 }
103 }
101 }
104 }
qml/Dash/Previews/PreviewRatingInput.qml+5
@@ -143,6 +143,11 @@ PreviewWidget {
143 TextArea {
143 TextArea {
144 id: reviewTextArea
144 id: reviewTextArea
145 objectName: "reviewTextArea"
145 objectName: "reviewTextArea"
146+ property bool inputMethodVisible: Qt.inputMethod.visible
147+ onInputMethodVisibleChanged: {
148+ if(inputMethodVisible && activeFocus)
149+ root.makeSureVisible(reviewTextArea);
150+ }
146 anchors {
151 anchors {
147 top: parent.top
152 top: parent.top
148 left: parent.left
153 left: parent.left
qml/Dash/Previews/PreviewWidget.qml+9
@@ -41,5 +41,14 @@ Item {
41 */
41 */
42 signal triggered(string widgetId, string actionId, var data)
42 signal triggered(string widgetId, string actionId, var data)
43
43
44+ /*! \brief This signal should be emitted when widget gains the focus
45+ * and input method popups.
46+ * And preview widget should reposition in visible area to avoid
47+ * keyboard appears over the widget.
48+ *
49+ * \param item, id of specified item which is needed to reposition.
50+ */
51+ signal makeSureVisible(var item)
52+
44 objectName: widgetId
53 objectName: widgetId
45}
54}
qml/Dash/Previews/PreviewWidgetFactory.qml+4
@@ -43,6 +43,9 @@ Loader {
43 //! Triggered signal forwarded from the widgets.
43 //! Triggered signal forwarded from the widgets.
44 signal triggered(string widgetId, string actionId, var data)
44 signal triggered(string widgetId, string actionId, var data)
45
45
46+ //! MakesureVisible signal forwarded from the widgets.
47+ signal makeSureVisible(var item)
48+
46 source: widgetSource
49 source: widgetSource
47
50
48 //! \cond private
51 //! \cond private
@@ -81,5 +84,6 @@ Loader {
81 Connections {
84 Connections {
82 target: root.item
85 target: root.item
83 onTriggered: root.triggered(widgetId, actionId, data)
86 onTriggered: root.triggered(widgetId, actionId, data)
87+ onMakeSureVisible: root.makeSureVisible(item)
84 }
88 }
85}
89}