Focus hack for menu fix

This commit is contained in:
Brad Davis 2016-01-21 15:09:36 -08:00
parent 3d46eda165
commit f343598d91
3 changed files with 39 additions and 8 deletions

View file

@ -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 }
}
}

View file

@ -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;
}
}

View file

@ -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