Fixing desktop QML loading, tablet clickthrough bugs

This commit is contained in:
Brad Davis 2017-11-07 12:42:26 -08:00
parent 2cd76be6c4
commit b7f31eb5b9
2 changed files with 67 additions and 28 deletions

View file

@ -202,8 +202,16 @@ Item {
}
function load(newSource, callback) {
loader.source = newSource;
loader.item = null;
if (loader.source == newSource) {
loader.loaded();
return;
}
if (loader.item) {
loader.item.destroy();
loader.item = null;
}
QmlSurface.load(newSource, loader, function(newItem) {
loader.item = newItem;
loader.item.width = loader.width;
@ -232,7 +240,6 @@ Item {
callback();
}
});
console.log("QQQ done calling QmlSurface.load")
}
}

View file

@ -59,18 +59,15 @@ Windows.ScrollingWindow {
}
function loadSource(url) {
loader.source = ""; // make sure we load the qml fresh each time.
loader.source = url;
loader.load(url)
}
function loadWebBase() {
loader.source = "";
loader.source = "WindowWebView.qml";
loader.load("hifi/tablet/TabletWebView.qml");
}
function loadTabletWebBase() {
loader.source = "";
loader.source = "./BlocksWebView.qml";
loader.load("hifi/tablet/BlocksWebView.qml");
}
function loadWebUrl(url, injectedJavaScriptUrl) {
@ -111,38 +108,73 @@ Windows.ScrollingWindow {
username = newUsername;
}
Loader {
// Hook up callback for clara.io download from the marketplace.
Connections {
id: eventBridgeConnection
target: eventBridge
onWebEventReceived: {
if (message.slice(0, 17) === "CLARA.IO DOWNLOAD") {
ApplicationInterface.addAssetToWorldFromURL(message.slice(18));
}
}
}
Item {
id: loader
objectName: "loader"
asynchronous: false
objectName: "loader";
property string source: "";
property var item: null;
height: pane.scrollHeight
width: pane.contentWidth
anchors.left: parent.left
anchors.top: parent.top
// Hook up callback for clara.io download from the marketplace.
Connections {
id: eventBridgeConnection
target: eventBridge
onWebEventReceived: {
if (message.slice(0, 17) === "CLARA.IO DOWNLOAD") {
ApplicationInterface.addAssetToWorldFromURL(message.slice(18));
}
signal loaded;
onWidthChanged: {
if (loader.item) {
loader.item.width = loader.width;
}
}
onHeightChanged: {
if (loader.item) {
loader.item.height = loader.height;
}
}
function load(newSource, callback) {
if (loader.source == newSource) {
loader.loaded();
return;
}
onLoaded: {
if (loader.item.hasOwnProperty("sendToScript")) {
loader.item.sendToScript.connect(tabletRoot.sendToScript);
if (loader.item) {
loader.item.destroy();
loader.item = null;
}
if (loader.item.hasOwnProperty("setRootMenu")) {
loader.item.setRootMenu(tabletRoot.rootMenu, tabletRoot.subMenu);
}
loader.item.forceActiveFocus();
QmlSurface.load(newSource, loader, function(newItem) {
loader.item = newItem;
loader.item.width = loader.width;
loader.item.height = loader.height;
loader.loaded();
if (loader.item.hasOwnProperty("sendToScript")) {
loader.item.sendToScript.connect(tabletRoot.sendToScript);
}
if (loader.item.hasOwnProperty("setRootMenu")) {
loader.item.setRootMenu(tabletRoot.rootMenu, tabletRoot.subMenu);
}
loader.item.forceActiveFocus();
if (callback) {
callback();
}
});
}
}
implicitWidth: 480
implicitHeight: 706
}