diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index ee3277e4c4..1996834378 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -16,12 +16,7 @@ FocusScope { property bool desktopRoot: true // The VR version of the primary menu - property var rootMenu: Menu { - id: rootMenu; objectName: "rootMenu" - Component.onCompleted: { - console.log("ROOT_MENU " + rootMenu); - } - } + property var rootMenu: Menu { objectName: "rootMenu" } QtObject { id: d @@ -210,7 +205,13 @@ FocusScope { // Debugging help for figuring out focus issues property var offscreenWindow; - onOffscreenWindowChanged: offscreenWindow.activeFocusItemChanged.connect(onWindowFocusChanged); + onOffscreenWindowChanged: { + offscreenWindow.activeFocusItemChanged.connect(onWindowFocusChanged); + focusHack.start(); + } + + FocusHack { id: focusHack; } + function onWindowFocusChanged() { console.log("Focus item is " + offscreenWindow.activeFocusItem); var focusedItem = offscreenWindow.activeFocusItem ; @@ -223,11 +224,14 @@ FocusScope { focusDebugger.height = rect.height } } + Rectangle { id: focusDebugger; z: 9999; visible: false; color: "red" ColorAnimation on color { from: "#7fffff00"; to: "#7f0000ff"; duration: 1000; loops: 9999 } } + + } diff --git a/interface/resources/qml/desktop/FocusHack.qml b/interface/resources/qml/desktop/FocusHack.qml new file mode 100644 index 0000000000..7514705983 --- /dev/null +++ b/interface/resources/qml/desktop/FocusHack.qml @@ -0,0 +1,26 @@ +import QtQuick 2.5 + +FocusScope { + id: root + + TextInput { + id: textInput; + focus: true + width: 10; height: 10 + onActiveFocusChanged: root.destroy() + } + + Timer { + id: focusTimer + running: false + interval: 100 + onTriggered: textInput.forceActiveFocus() + } + + function start() { + focusTimer.running = true; + } +} + + + diff --git a/tests/ui/qmlscratch.pro b/tests/ui/qmlscratch.pro index 97f2b9b6f7..f6859b743a 100644 --- a/tests/ui/qmlscratch.pro +++ b/tests/ui/qmlscratch.pro @@ -86,5 +86,6 @@ DISTFILES += \ ../../interface/resources/qml/menus/MenuMouseHandler.qml \ ../../interface/resources/qml/menus/VrMenuItem.qml \ ../../interface/resources/qml/menus/VrMenuView.qml \ - ../../interface/resources/qml/windows/ModalWindow.qml + ../../interface/resources/qml/windows/ModalWindow.qml \ + ../../interface/resources/qml/desktop/FocusHack.qml