Commit c2e06168 authored by DonLakeFlyer's avatar DonLakeFlyer

Work on getting keyboard focus to right place

parent 8e1a3fd9
......@@ -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 === "") {
......
......@@ -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 {
......
......@@ -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()
}
}
}
......@@ -68,6 +68,7 @@ FactPanel {
"viewPanel": viewPanel
})
dialog.setupDialogButtons(buttons)
dialog.focus = true
viewPanel.enabled = false
}
......
......@@ -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
......
......@@ -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
......
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