I have MapView as a main window element and I want it to respond to some keyboard presses. But if I click, for example, on the ManuBar and then on the map, the focus remains on the menu. I could handle mouse clicks to set the focus:
ApplicationWindow {
width: 400
height: 300
visible: true
MapView {
id: mapView
anchors.fill: parent
focus: true
MouseArea {
anchors.fill: parent
onClicked: {
mapView.forceActiveFocus()
}
onLongPress: {
mapView.forceActiveFocus()
}
onDoubleClicked: {
mapView.forceActiveFocus()
}
/* right-click events */
}
}
}
But I don't think it's the optimal way to do this. Can you suggest anything to solve the problem?