diff --git a/src/FactSystem/FactControls/FactTextField.qml b/src/FactSystem/FactControls/FactTextField.qml index f17ea565cb063c8c2c8c3766ec7a697355c1e7d0..ab66d9f2d5deb57da887ebaca77fa1f1078558a8 100644 --- a/src/FactSystem/FactControls/FactTextField.qml +++ b/src/FactSystem/FactControls/FactTextField.qml @@ -20,16 +20,11 @@ QGCTextField { property string _validateString - // At this point all Facts are numeric inputMethodHints: ((fact && fact.typeIsString) || ScreenTools.isiOS) ? Qt.ImhNone : // iOS numeric keyboard has no done button, we can't use it Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard onEditingFinished: { - if (ScreenTools.isMobile) { - // Toss focus on mobile after Done on virtual keyboard. Prevent strange interactions. - focus = false - } if (typeof qgcView !== 'undefined' && qgcView) { var errorString = fact.validate(text, false /* convertOnly */) if (errorString === "") { diff --git a/src/QmlControls/ParameterEditorDialog.qml b/src/QmlControls/ParameterEditorDialog.qml index 4a97a174dcc4dbef0a1254f67f63f10028ad9236..404a747d6e183d4be00dd92979f7cd4b1cf8a6c3 100644 --- a/src/QmlControls/ParameterEditorDialog.qml +++ b/src/QmlControls/ParameterEditorDialog.qml @@ -20,13 +20,16 @@ import QGroundControl.FactControls 1.0 import QGroundControl.ScreenTools 1.0 QGCViewDialog { - id: root + id: root + focus: true property Fact fact property bool showRCToParam: false property bool validate: false property string validateValue + signal valueChanged + property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 20 property bool _longDescriptionAvailable: fact.longDescription != "" property bool _editingParameter: fact.componentId != 0 @@ -41,15 +44,18 @@ QGCViewDialog { if (bitmaskColumn.visible && !manualEntry.checked) { fact.value = bitmaskValue(); fact.valueChanged(fact.value) + valueChanged() hideDialog(); } else if (factCombo.visible && !manualEntry.checked) { fact.enumIndex = factCombo.currentIndex + valueChanged() hideDialog() } else { var errorString = fact.validate(valueField.text, forceSave.checked) if (errorString === "") { fact.value = valueField.text fact.valueChanged(fact.value) + valueChanged() hideDialog() } else { validationError.text = errorString @@ -85,12 +91,8 @@ QGCViewDialog { } } - // set focus to the text field when becoming visible (in case of an Enum, - // the valueField is not visible, but it's not an issue because the combo - // box cannot have a focus) - onVisibleChanged: if (visible && !ScreenTools.isMobile) valueField.forceActiveFocus() - QGCFlickable { + id: flickable anchors.fill: parent contentHeight: _column.y + _column.height flickableDirection: Flickable.VerticalFlick @@ -120,9 +122,10 @@ QGCViewDialog { unitsLabel: fact.units showUnits: fact.units != "" Layout.fillWidth: true - inputMethodHints: ScreenTools.isiOS ? - Qt.ImhNone : // iOS numeric keyboard has not done button, we can't use it - Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard + focus: true + inputMethodHints: (fact.typeIsString || ScreenTools.isiOS) ? + Qt.ImhNone : // iOS numeric keyboard has no done button, we can't use it + Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard } QGCButton { diff --git a/src/QmlControls/QGCTextField.qml b/src/QmlControls/QGCTextField.qml index 459a775bc3305c3ac4922690b3f7db362b6c3b7c..f1a78e0b0355e17f00b6316d46cde021ea4f41e8 100644 --- a/src/QmlControls/QGCTextField.qml +++ b/src/QmlControls/QGCTextField.qml @@ -7,7 +7,10 @@ import QGroundControl.Palette 1.0 import QGroundControl.ScreenTools 1.0 TextField { - id: root + id: root + textColor: qgcPal.textFieldText + implicitHeight: ScreenTools.implicitTextFieldHeight + activeFocusOnPress: true property bool showUnits: false property bool showHelp: false @@ -17,18 +20,11 @@ TextField { property real _helpLayoutWidth: 0 - Component.onCompleted: { - if (typeof qgcTextFieldforwardKeysTo !== 'undefined') { - root.Keys.forwardTo = [qgcTextFieldforwardKeysTo] - } - } + Component.onCompleted: selectAllIfActiveFocus() + onActiveFocusChanged: selectAllIfActiveFocus() QGCPalette { id: qgcPal; colorGroupEnabled: enabled } - textColor: qgcPal.textFieldText - - implicitHeight: ScreenTools.implicitTextFieldHeight - onEditingFinished: { if (ScreenTools.isMobile) { // Toss focus on mobile after Done on virtual keyboard. Prevent strange interactions. @@ -36,6 +32,12 @@ TextField { } } + function selectAllIfActiveFocus() { + if (activeFocus) { + selectAll() + } + } + QGCLabel { id: unitsLabelWidthGenerator text: unitsLabel @@ -59,7 +61,7 @@ TextField { Rectangle { anchors.fill: parent - border.color: control.activeFocus ? "#47b" : "#999" + border.color: root.activeFocus ? "#47b" : "#999" color: qgcPal.textField } @@ -114,10 +116,4 @@ TextField { padding.right: control._helpLayoutWidth //control.showUnits ? unitsLabelWidthGenerator.width : control.__contentHeight * 0.333 } - - onActiveFocusChanged: { - if (activeFocus) { - selectAll() - } - } } diff --git a/src/QmlControls/QGCView.qml b/src/QmlControls/QGCView.qml index b50ac571e77367df7375af4404b21f47676c0939..4a4c2cef313167c767b2033012aef975f2cedc94 100644 --- a/src/QmlControls/QGCView.qml +++ b/src/QmlControls/QGCView.qml @@ -68,6 +68,7 @@ FactPanel { "viewPanel": viewPanel }) dialog.setupDialogButtons(buttons) + dialog.focus = true viewPanel.enabled = false } diff --git a/src/QmlControls/QGCViewDialog.qml b/src/QmlControls/QGCViewDialog.qml index 0c1e02b1c23ad98b26bc6d6daa8bc78a2b1b63e1..228432734d119843e2b6832008775ca1c5e0aae0 100644 --- a/src/QmlControls/QGCViewDialog.qml +++ b/src/QmlControls/QGCViewDialog.qml @@ -17,8 +17,6 @@ import QGroundControl.FactControls 1.0 import QGroundControl.ScreenTools 1.0 FactPanel { - property var qgcTextFieldforwardKeysTo: this ///< Causes all QGCTextFields to forward keys here if they have focus - property real defaultTextWidth: ScreenTools.defaultFontPixelWidth property real defaultTextHeight: ScreenTools.defaultFontPixelHeight diff --git a/src/QmlControls/QGCViewDialogContainer.qml b/src/QmlControls/QGCViewDialogContainer.qml index dda82095d2e11763365cad8d9cb7d3e6790e937b..f22dc7a55a275bee3dfb746191d2ca8f5d2a3996 100644 --- a/src/QmlControls/QGCViewDialogContainer.qml +++ b/src/QmlControls/QGCViewDialogContainer.qml @@ -15,9 +15,10 @@ import QGroundControl.Controls 1.0 import QGroundControl.Palette 1.0 import QGroundControl.ScreenTools 1.0 -Item { - id: _root - z: 5000 +FocusScope { + id: _root + z: 5000 + focus: true property alias dialogWidth: _dialogPanel.width property alias dialogTitle: titleLabel.text @@ -182,6 +183,7 @@ Item { anchors.top: _spacer.bottom anchors.bottom: parent.bottom sourceComponent: _dialogComponent + focus: true property bool acceptAllowed: _acceptButton.visible property bool rejectAllowed: _rejectButton.visible