Comment 2 for bug 1545802

Revision history for this message
Olivier Tilloy (osomon) wrote :

I just tried a very ugly hack to work around the issue:

TextField {
  objectName: "addressBarTextField"
  onActiveFocusChanged: {
    if (activeFocus) {
      var textInput = findChild(textField, "text_input")
      console.log("address bar got active focus, text input =", textInput)
      textInput.forceActiveFocus()
      console.log("after forcing active focus on text input", textInput)
    }
  }
}

Where findChild() is copied from UbuntuTestCase to recursively search for a given descendant by objectName.
Well I’m seeing this output:

qml: AFI: QQuickTextInput(0xb779c760, "text_input")
qml: address bar got active focus, text input = QQuickTextInput(0xb779c760, "text_input")
qml: after forcing active focus on text input QQuickTextInput(0xb779c760, "text_input")
qml: AFI: TextField_QMLTYPE_61_QML_146(0xb7793c28, "addressBarTextField")

So this hack isn’t even working. But it seems to indicate that active focus is removed from the TextInput, but remains on the ancestor TextField. Why that happens remains to be explained.