Commit c2e06168 authored by DonLakeFlyer's avatar DonLakeFlyer

Work on getting keyboard focus to right place

parent 8e1a3fd9
...@@ -20,16 +20,11 @@ QGCTextField { ...@@ -20,16 +20,11 @@ QGCTextField {
property string _validateString property string _validateString
// At this point all Facts are numeric
inputMethodHints: ((fact && fact.typeIsString) || ScreenTools.isiOS) ? inputMethodHints: ((fact && fact.typeIsString) || ScreenTools.isiOS) ?
Qt.ImhNone : // iOS numeric keyboard has no done button, we can't use it Qt.ImhNone : // iOS numeric keyboard has no done button, we can't use it
Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard
onEditingFinished: { onEditingFinished: {
if (ScreenTools.isMobile) {
// Toss focus on mobile after Done on virtual keyboard. Prevent strange interactions.
focus = false
}
if (typeof qgcView !== 'undefined' && qgcView) { if (typeof qgcView !== 'undefined' && qgcView) {
var errorString = fact.validate(text, false /* convertOnly */) var errorString = fact.validate(text, false /* convertOnly */)
if (errorString === "") { if (errorString === "") {
......
...@@ -20,13 +20,16 @@ import QGroundControl.FactControls 1.0 ...@@ -20,13 +20,16 @@ import QGroundControl.FactControls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
QGCViewDialog { QGCViewDialog {
id: root id: root
focus: true
property Fact fact property Fact fact
property bool showRCToParam: false property bool showRCToParam: false
property bool validate: false property bool validate: false
property string validateValue property string validateValue
signal valueChanged
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 20 property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 20
property bool _longDescriptionAvailable: fact.longDescription != "" property bool _longDescriptionAvailable: fact.longDescription != ""
property bool _editingParameter: fact.componentId != 0 property bool _editingParameter: fact.componentId != 0
...@@ -41,15 +44,18 @@ QGCViewDialog { ...@@ -41,15 +44,18 @@ QGCViewDialog {
if (bitmaskColumn.visible && !manualEntry.checked) { if (bitmaskColumn.visible && !manualEntry.checked) {
fact.value = bitmaskValue(); fact.value = bitmaskValue();
fact.valueChanged(fact.value) fact.valueChanged(fact.value)
valueChanged()
hideDialog(); hideDialog();
} else if (factCombo.visible && !manualEntry.checked) { } else if (factCombo.visible && !manualEntry.checked) {
fact.enumIndex = factCombo.currentIndex fact.enumIndex = factCombo.currentIndex
valueChanged()
hideDialog() hideDialog()
} else { } else {
var errorString = fact.validate(valueField.text, forceSave.checked) var errorString = fact.validate(valueField.text, forceSave.checked)
if (errorString === "") { if (errorString === "") {
fact.value = valueField.text fact.value = valueField.text
fact.valueChanged(fact.value) fact.valueChanged(fact.value)
valueChanged()
hideDialog() hideDialog()
} else { } else {
validationError.text = errorString validationError.text = errorString
...@@ -85,12 +91,8 @@ QGCViewDialog { ...@@ -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 { QGCFlickable {
id: flickable
anchors.fill: parent anchors.fill: parent
contentHeight: _column.y + _column.height contentHeight: _column.y + _column.height
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
...@@ -120,9 +122,10 @@ QGCViewDialog { ...@@ -120,9 +122,10 @@ QGCViewDialog {
unitsLabel: fact.units unitsLabel: fact.units
showUnits: fact.units != "" showUnits: fact.units != ""
Layout.fillWidth: true Layout.fillWidth: true
inputMethodHints: ScreenTools.isiOS ? focus: true
Qt.ImhNone : // iOS numeric keyboard has not done button, we can't use it inputMethodHints: (fact.typeIsString || ScreenTools.isiOS) ?
Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard Qt.ImhNone : // iOS numeric keyboard has no done button, we can't use it
Qt.ImhFormattedNumbersOnly // Forces use of virtual numeric keyboard
} }
QGCButton { QGCButton {
......
...@@ -7,7 +7,10 @@ import QGroundControl.Palette 1.0 ...@@ -7,7 +7,10 @@ import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
TextField { TextField {
id: root id: root
textColor: qgcPal.textFieldText
implicitHeight: ScreenTools.implicitTextFieldHeight
activeFocusOnPress: true
property bool showUnits: false property bool showUnits: false
property bool showHelp: false property bool showHelp: false
...@@ -17,18 +20,11 @@ TextField { ...@@ -17,18 +20,11 @@ TextField {
property real _helpLayoutWidth: 0 property real _helpLayoutWidth: 0
Component.onCompleted: { Component.onCompleted: selectAllIfActiveFocus()
if (typeof qgcTextFieldforwardKeysTo !== 'undefined') { onActiveFocusChanged: selectAllIfActiveFocus()
root.Keys.forwardTo = [qgcTextFieldforwardKeysTo]
}
}
QGCPalette { id: qgcPal; colorGroupEnabled: enabled } QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
textColor: qgcPal.textFieldText
implicitHeight: ScreenTools.implicitTextFieldHeight
onEditingFinished: { onEditingFinished: {
if (ScreenTools.isMobile) { if (ScreenTools.isMobile) {
// Toss focus on mobile after Done on virtual keyboard. Prevent strange interactions. // Toss focus on mobile after Done on virtual keyboard. Prevent strange interactions.
...@@ -36,6 +32,12 @@ TextField { ...@@ -36,6 +32,12 @@ TextField {
} }
} }
function selectAllIfActiveFocus() {
if (activeFocus) {
selectAll()
}
}
QGCLabel { QGCLabel {
id: unitsLabelWidthGenerator id: unitsLabelWidthGenerator
text: unitsLabel text: unitsLabel
...@@ -59,7 +61,7 @@ TextField { ...@@ -59,7 +61,7 @@ TextField {
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
border.color: control.activeFocus ? "#47b" : "#999" border.color: root.activeFocus ? "#47b" : "#999"
color: qgcPal.textField color: qgcPal.textField
} }
...@@ -114,10 +116,4 @@ TextField { ...@@ -114,10 +116,4 @@ TextField {
padding.right: control._helpLayoutWidth //control.showUnits ? unitsLabelWidthGenerator.width : control.__contentHeight * 0.333 padding.right: control._helpLayoutWidth //control.showUnits ? unitsLabelWidthGenerator.width : control.__contentHeight * 0.333
} }
onActiveFocusChanged: {
if (activeFocus) {
selectAll()
}
}
} }
...@@ -68,6 +68,7 @@ FactPanel { ...@@ -68,6 +68,7 @@ FactPanel {
"viewPanel": viewPanel "viewPanel": viewPanel
}) })
dialog.setupDialogButtons(buttons) dialog.setupDialogButtons(buttons)
dialog.focus = true
viewPanel.enabled = false viewPanel.enabled = false
} }
......
...@@ -17,8 +17,6 @@ import QGroundControl.FactControls 1.0 ...@@ -17,8 +17,6 @@ import QGroundControl.FactControls 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
FactPanel { FactPanel {
property var qgcTextFieldforwardKeysTo: this ///< Causes all QGCTextFields to forward keys here if they have focus
property real defaultTextWidth: ScreenTools.defaultFontPixelWidth property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
property real defaultTextHeight: ScreenTools.defaultFontPixelHeight property real defaultTextHeight: ScreenTools.defaultFontPixelHeight
......
...@@ -15,9 +15,10 @@ import QGroundControl.Controls 1.0 ...@@ -15,9 +15,10 @@ import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
Item { FocusScope {
id: _root id: _root
z: 5000 z: 5000
focus: true
property alias dialogWidth: _dialogPanel.width property alias dialogWidth: _dialogPanel.width
property alias dialogTitle: titleLabel.text property alias dialogTitle: titleLabel.text
...@@ -182,6 +183,7 @@ Item { ...@@ -182,6 +183,7 @@ Item {
anchors.top: _spacer.bottom anchors.top: _spacer.bottom
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
sourceComponent: _dialogComponent sourceComponent: _dialogComponent
focus: true
property bool acceptAllowed: _acceptButton.visible property bool acceptAllowed: _acceptButton.visible
property bool rejectAllowed: _rejectButton.visible property bool rejectAllowed: _rejectButton.visible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment