Merge pull request #6886 from jherico/browser_fix

Frame construction in onCompleted was breaking the browser keyboard focus
This commit is contained in:
Brad Hefta-Gaub 2016-01-22 09:50:11 -08:00
commit c9d9bbe218
9 changed files with 59 additions and 65 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

@ -8,23 +8,20 @@ import "../windows"
import "../styles"
// Work in progress....
Window {
ModalWindow {
id: root
HifiConstants { id: hifi }
signal selectedFile(var file);
signal canceled();
anchors.centerIn: parent
resizable: true
width: 640
height: 480
modality: Qt.ApplicationModal
property string settingsName: ""
property alias folder: folderModel.folder
property alias filterModel: selectionType.model
Rectangle {
anchors.fill: parent
color: "white"

View file

@ -7,19 +7,14 @@ import "../styles"
import "../windows"
// FIXME respect default button functionality
// FIXME force active focus at all times (modal dialog)
Window {
ModalWindow {
id: root
HifiConstants { id: hifi }
implicitWidth: 640
implicitHeight: 320
destroyOnCloseButton: true
destroyOnInvisible: true
visible: true
modality: Qt.ApplicationModal
anchors.centerIn: parent
frame: ModalFrame {}
signal selected(int button);

View file

@ -17,9 +17,10 @@ Frame {
color: "#7f7f7f7f";
radius: 3;
MouseArea {
enabled: window.visible
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onClicked: { }
onClicked: {}
onDoubleClicked: {}
onPressAndHold: {}
onReleased: {}

View file

@ -0,0 +1,12 @@
import QtQuick 2.5
import "."
Window {
id: root
anchors.centerIn: parent
modality: Qt.ApplicationModal
frame: ModalFrame{}
}

View file

@ -69,28 +69,9 @@ Fadable {
// Default to a standard frame. Can be overriden to provide custom
// frame styles, like a full desktop frame to simulate a modal window
property var frame;
property var frame: DefaultFrame { }
Component {
id: defaultFrameBuilder;
DefaultFrame { anchors.fill: parent }
}
Component {
id: modalFrameBuilder;
ModalFrame { anchors.fill: parent }
}
Component.onCompleted: {
if (!frame) {
if (modality === Qt.NonModal) {
frame = defaultFrameBuilder.createObject(window);
} else {
frame = modalFrameBuilder.createObject(window);
}
}
raise();
}
Component.onCompleted: raise();
children: [ frame, content, activator ]

View file

@ -132,11 +132,6 @@ ApplicationWindow {
console.log(appWindow.activeFocusItem);
}
}
Button {
text: "Preferences"
property var preferencesComponent: Component { PreferencesDialog { } }
onClicked: preferencesComponent.createObject(desktop);
}
}
Window {
@ -194,25 +189,6 @@ ApplicationWindow {
color: "yellow"
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
Component {
id: menuBuilder
VrMenuView { }
}
onClicked: {
console.log("zzz")
var menuItems = menuItemsToModel(stubMenu);
var newMenu = menuBuilder.createObject(desktop, { source: stubMenu, items: menuItems });
newMenu.x = mouseX
newMenu.y = mouseY
}
}
}
/*

View file

@ -85,5 +85,7 @@ DISTFILES += \
../../interface/resources/qml/hifi/Desktop.qml \
../../interface/resources/qml/menus/MenuMouseHandler.qml \
../../interface/resources/qml/menus/VrMenuItem.qml \
../../interface/resources/qml/menus/VrMenuView.qml
../../interface/resources/qml/menus/VrMenuView.qml \
../../interface/resources/qml/windows/ModalWindow.qml \
../../interface/resources/qml/desktop/FocusHack.qml