Skip to content

Commit c878e3f

Browse files
committed
Improved keyboard show and hide behavior on mobile
1 parent de5ccaa commit c878e3f

File tree

12 files changed

+67
-12
lines changed

12 files changed

+67
-12
lines changed

mobile/DoubleSpinBox.qml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
// Based on https://stackoverflow.com/questions/43406830/how-to-use-float-in-a-qml-spinbox
2121

22-
import QtQuick 2.0
23-
import QtQuick.Controls 2.2
22+
import QtQuick 2.15
23+
import QtQuick.Controls 2.15
2424

2525
Item {
2626
height: spinbox.implicitHeight
@@ -64,6 +64,12 @@ Item {
6464
}
6565

6666
valueFromText: function(text, locale) {
67+
// For some reason android does not hide the keyboard
68+
// when finishing the edit. Hiding it from here seems
69+
// to behave as expected. TODO: Test on ios and different
70+
// phones in general.
71+
Qt.inputMethod.hide()
72+
6773
return Math.round(parseFloat(text.replace(",", ".").
6874
replace(suffix, "").
6975
replace(prefix, "")) * factor)

mobile/ImageButton.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Item {
3232
id: control
3333
anchors.fill: parent
3434
flat: true
35+
focusPolicy: Qt.NoFocus
3536

3637
onClicked: {
3738
rootItem.clicked()

mobile/LogBox.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Item {
5959
Button {
6060
text: "Reset"
6161
Layout.fillWidth: true
62+
focusPolicy: Qt.NoFocus
6263

6364
onClicked: {
6465
rtLogFileText.text = StandardPaths.writableLocation(StandardPaths.DocumentsLocation) + "/logs"
@@ -68,6 +69,7 @@ Item {
6869
Button {
6970
text: "Browse"
7071
Layout.fillWidth: true
72+
focusPolicy: Qt.NoFocus
7173

7274
onClicked: {
7375
if (Utility.requestFilePermission()) {
@@ -142,6 +144,7 @@ Item {
142144
text: "Enable RT Data Logging"
143145
Layout.fillWidth: true
144146
Layout.columnSpan: 3
147+
focusPolicy: Qt.NoFocus
145148

146149
onClicked: {
147150
if (checked && !VescIf.isPortConnected()) {

mobile/ParamEditBitfield.qml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,29 @@ Item {
146146
Layout.fillWidth: true;
147147
columns: 2
148148
CheckBox { Layout.topMargin: 0; Layout.bottomMargin: -8; Layout.fillWidth: true;
149-
id: b0Box; text: "B0"; onCheckedChanged: updateFromBoxes(); }
149+
id: b0Box; focusPolicy: Qt.NoFocus; text: "B0"; onCheckedChanged: updateFromBoxes(); }
150150
CheckBox { Layout.topMargin: 0; Layout.bottomMargin: -8; Layout.fillWidth: true;
151-
id: b1Box; text: "B1"; onCheckedChanged: updateFromBoxes(); }
151+
id: b1Box; focusPolicy: Qt.NoFocus; text: "B1"; onCheckedChanged: updateFromBoxes(); }
152152
CheckBox { Layout.topMargin: -8; Layout.bottomMargin: -8; Layout.fillWidth: true;
153-
id: b2Box; text: "B2"; onCheckedChanged: updateFromBoxes(); }
153+
id: b2Box; focusPolicy: Qt.NoFocus; text: "B2"; onCheckedChanged: updateFromBoxes(); }
154154
CheckBox { Layout.topMargin: -8; Layout.bottomMargin: -8; Layout.fillWidth: true;
155-
id: b3Box; text: "B3"; onCheckedChanged: updateFromBoxes(); }
155+
id: b3Box; focusPolicy: Qt.NoFocus; text: "B3"; onCheckedChanged: updateFromBoxes(); }
156156
CheckBox { Layout.topMargin: -8; Layout.bottomMargin: -8; Layout.fillWidth: true;
157-
id: b4Box; text: "B4"; onCheckedChanged: updateFromBoxes(); }
157+
id: b4Box; focusPolicy: Qt.NoFocus; text: "B4"; onCheckedChanged: updateFromBoxes(); }
158158
CheckBox { Layout.topMargin: -8; Layout.bottomMargin: -8; Layout.fillWidth: true;
159-
id: b5Box; text: "B5"; onCheckedChanged: updateFromBoxes(); }
159+
id: b5Box; focusPolicy: Qt.NoFocus; text: "B5"; onCheckedChanged: updateFromBoxes(); }
160160
CheckBox { Layout.topMargin: -8; Layout.bottomMargin: -8; Layout.fillWidth: true;
161-
id: b6Box; text: "B6"; onCheckedChanged: updateFromBoxes(); }
161+
id: b6Box; focusPolicy: Qt.NoFocus; text: "B6"; onCheckedChanged: updateFromBoxes(); }
162162
CheckBox { Layout.topMargin: -8; Layout.bottomMargin: -8; Layout.fillWidth: true;
163-
id: b7Box; text: "B7"; onCheckedChanged: updateFromBoxes(); }
163+
id: b7Box; focusPolicy: Qt.NoFocus; text: "B7"; onCheckedChanged: updateFromBoxes(); }
164164
}
165165

166166
RowLayout {
167167
Layout.fillWidth: true
168168
Button {
169169
id: nowButton
170+
focusPolicy: Qt.NoFocus
171+
170172
Layout.fillWidth: true
171173
Layout.preferredWidth: 500
172174
flat: true
@@ -179,6 +181,8 @@ Item {
179181

180182
Button {
181183
id: defaultButton
184+
focusPolicy: Qt.NoFocus
185+
182186
Layout.fillWidth: true
183187
Layout.preferredWidth: 500
184188
flat: true
@@ -191,6 +195,8 @@ Item {
191195

192196
Button {
193197
id: helpButton
198+
focusPolicy: Qt.NoFocus
199+
194200
Layout.fillWidth: true
195201
Layout.preferredWidth: 500
196202
flat: true

mobile/ParamEditBool.qml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Item {
7373

7474
Switch {
7575
id: boolSwitch
76+
focusPolicy: Qt.NoFocus
77+
7678
Layout.fillWidth: true
7779

7880
onCheckedChanged: {
@@ -89,6 +91,8 @@ Item {
8991
Layout.fillWidth: true
9092
Button {
9193
id: nowButton
94+
focusPolicy: Qt.NoFocus
95+
9296
Layout.fillWidth: true
9397
Layout.preferredWidth: 500
9498
flat: true
@@ -101,6 +105,8 @@ Item {
101105

102106
Button {
103107
id: defaultButton
108+
focusPolicy: Qt.NoFocus
109+
104110
Layout.fillWidth: true
105111
Layout.preferredWidth: 500
106112
flat: true
@@ -113,6 +119,8 @@ Item {
113119

114120
Button {
115121
id: helpButton
122+
focusPolicy: Qt.NoFocus
123+
116124
Layout.fillWidth: true
117125
Layout.preferredWidth: 500
118126
flat: true

mobile/ParamEditDouble.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ Item {
147147

148148
RowLayout {
149149
Layout.fillWidth: true
150+
150151
Button {
151152
id: nowButton
153+
focusPolicy: Qt.NoFocus
154+
152155
Layout.fillWidth: true
153156
Layout.preferredWidth: 500
154157
flat: true
@@ -161,6 +164,8 @@ Item {
161164

162165
Button {
163166
id: defaultButton
167+
focusPolicy: Qt.NoFocus
168+
164169
Layout.fillWidth: true
165170
Layout.preferredWidth: 500
166171
flat: true
@@ -173,6 +178,8 @@ Item {
173178

174179
Button {
175180
id: helpButton
181+
focusPolicy: Qt.NoFocus
182+
176183
Layout.fillWidth: true
177184
Layout.preferredWidth: 500
178185
flat: true

mobile/ParamEditEnum.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Item {
7777

7878
ComboBox {
7979
id: enumBox
80+
focusPolicy: Qt.NoFocus
8081
Layout.fillWidth: true
8182

8283
background: Rectangle {
@@ -101,6 +102,8 @@ Item {
101102
Layout.fillWidth: true
102103
Button {
103104
id: nowButton
105+
focusPolicy: Qt.NoFocus
106+
104107
Layout.fillWidth: true
105108
Layout.preferredWidth: 500
106109
flat: true
@@ -113,6 +116,8 @@ Item {
113116

114117
Button {
115118
id: defaultButton
119+
focusPolicy: Qt.NoFocus
120+
116121
Layout.fillWidth: true
117122
Layout.preferredWidth: 500
118123
flat: true
@@ -125,6 +130,8 @@ Item {
125130

126131
Button {
127132
id: helpButton
133+
focusPolicy: Qt.NoFocus
134+
128135
Layout.fillWidth: true
129136
Layout.preferredWidth: 500
130137
flat: true

mobile/ParamEditInt.qml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20-
import QtQuick 2.0
21-
import QtQuick.Controls 2.2
20+
import QtQuick 2.15
21+
import QtQuick.Controls 2.15
2222
import QtQuick.Layouts 1.3
2323

2424
import Vedder.vesc.vescinterface 1.0
@@ -161,6 +161,8 @@ Item {
161161
Layout.fillWidth: true
162162
Button {
163163
id: nowButton
164+
focusPolicy: Qt.NoFocus
165+
164166
Layout.fillWidth: true
165167
Layout.preferredWidth: 500
166168
flat: true
@@ -173,6 +175,8 @@ Item {
173175

174176
Button {
175177
id: defaultButton
178+
focusPolicy: Qt.NoFocus
179+
176180
Layout.fillWidth: true
177181
Layout.preferredWidth: 500
178182
flat: true
@@ -185,6 +189,8 @@ Item {
185189

186190
Button {
187191
id: helpButton
192+
focusPolicy: Qt.NoFocus
193+
188194
Layout.fillWidth: true
189195
Layout.preferredWidth: 500
190196
flat: true

mobile/ParamEditString.qml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ Item {
105105
Layout.fillWidth: true
106106
Button {
107107
id: nowButton
108+
focusPolicy: Qt.NoFocus
109+
108110
Layout.fillWidth: true
109111
Layout.preferredWidth: 500
110112
flat: true
@@ -117,6 +119,8 @@ Item {
117119

118120
Button {
119121
id: defaultButton
122+
focusPolicy: Qt.NoFocus
123+
120124
Layout.fillWidth: true
121125
Layout.preferredWidth: 500
122126
flat: true
@@ -129,6 +133,8 @@ Item {
129133

130134
Button {
131135
id: helpButton
136+
focusPolicy: Qt.NoFocus
137+
132138
Layout.fillWidth: true
133139
Layout.preferredWidth: 500
134140
flat: true

mobile/TcpBox.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Item {
4242

4343
CheckBox {
4444
id: tcpServerEnBox
45+
focusPolicy: Qt.NoFocus
4546
text: "Activate Bridge"
4647
Layout.fillWidth: true
4748
Layout.columnSpan: 2

0 commit comments

Comments
 (0)