So far focus was taken only by text inputs. Now that we have focus handling, a simple focus: true does not mean that activeFocus will also be taken when a previous component was having focus.
When the popover is long-pressed, it takes the focus, and then when closed, popover restores the focus to its "caller" that being the list item in the file list. So when the Dialog is opened, the list item is the active focus. In order to grab the focus you need to call forceActiveFocus() on Dialog completion. See the following code:
So far focus was taken only by text inputs. Now that we have focus handling, a simple focus: true does not mean that activeFocus will also be taken when a previous component was having focus.
When the popover is long-pressed, it takes the focus, and then when closed, popover restores the focus to its "caller" that being the list item in the file list. So when the Dialog is opened, the list item is the active focus. In order to grab the focus you need to call forceActiveFocus() on Dialog completion. See the following code:
import QtQuick 2.2 Components. Popups 1.0 Components. ListItems 1.0
import Ubuntu.Components 1.1
import Ubuntu.
import Ubuntu.
MainView {
width: units.gu(40)
height: units.gu(71)
Connections {
onActiveFocusI temChanged: print(" activeFocus: ", window. activeFocusItem )
target: window
}
Standard { open(popoverCom ponent, caller)
id: caller
objectName: "MainListItem"
text: "Press to open popover"
onClicked: PopupUtils.
}
Component {
contentWid th: units.gu(20)
contentHei ght: line.height
Standard {
objectName: "PopoverListItem"
text: "Open dialog"
onClicked: {
PopupUtil s.close( popover)
PopupUtil s.open( inputDialogComp onent)
id: popoverComponent
Popover {
id: popover
id: line
}
}
}
}
Component { onent
id: inputDialogComp
Dialog {
id: inputDialog
title: "Input Dialog"
id: input
}
Button {
text: "Close"
onClicked: PopupUtils. close(inputDial og)
}
// Component. onCompleted: input.forceActi veFocus( )
}
}
}