Add keyboard

This commit is contained in:
David Rowe 2017-03-14 21:36:57 +13:00
parent f3a99a2437
commit d141d5b683
2 changed files with 54 additions and 12 deletions

View file

@ -89,9 +89,7 @@ Preference {
root.browser = null; root.browser = null;
}); });
} else { } else {
root.browser = tabletAvatarBrowserBuilder.createObject(tabletRoot, { root.browser = tabletAvatarBrowserBuilder.createObject(tabletRoot);
createGlobalEventBridgeSource: eventBridgeJavaScriptToInject
});
// Make dialog modal. // Make dialog modal.
tabletRoot.openModal = root.browser; tabletRoot.openModal = root.browser;
@ -101,7 +99,9 @@ Preference {
Component { Component {
id: tabletAvatarBrowserBuilder; id: tabletAvatarBrowserBuilder;
TabletAvatarBrowser { } TabletAvatarBrowser {
eventBridge: tabletRoot.eventBridge
}
} }
} }
} }

View file

@ -25,17 +25,16 @@ Item {
property var result property var result
property bool keyboardEnabled: false
property bool keyboardRaised: false
property bool punctuationMode: false
signal selected(var modelUrl) signal selected(var modelUrl)
signal canceled() signal canceled()
anchors.fill: parent property alias eventBridge: eventBridgeWrapper.eventBridge
/* anchors.fill: parent
Rectangle {
id: pane // Surrogate for ScrollingWindow's pane.
anchors.fill: parent
}
*/
BaseWebView { BaseWebView {
id: webview id: webview
@ -48,6 +47,32 @@ Item {
right: parent.right right: parent.right
bottom: footer.top bottom: footer.top
} }
QtObject {
id: eventBridgeWrapper
WebChannel.id: "eventBridgeWrapper"
property var eventBridge;
}
webChannel.registeredObjects: [eventBridgeWrapper]
// Create a global EventBridge object for raiseAndLowerKeyboard.
WebEngineScript {
id: createGlobalEventBridge
sourceCode: eventBridgeJavaScriptToInject
injectionPoint: WebEngineScript.DocumentCreation
worldId: WebEngineScript.MainWorld
}
// Detect when may want to raise and lower keyboard.
WebEngineScript {
id: raiseAndLowerKeyboard
injectionPoint: WebEngineScript.Deferred
sourceUrl: resourceDirectoryUrl + "html/raiseAndLowerKeyboard.js"
worldId: WebEngineScript.MainWorld
}
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard ]
} }
Rectangle { Rectangle {
@ -57,7 +82,7 @@ Item {
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
bottom: parent.bottom bottom: keyboard.top
} }
color: hifi.colors.baseGray color: hifi.colors.baseGray
@ -76,4 +101,21 @@ Item {
} }
} }
} }
Keyboard {
id: keyboard
raised: parent.keyboardEnabled && parent.keyboardRaised
numeric: parent.punctuationMode
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
Component.onCompleted: {
keyboardEnabled = HMD.active;
}
} }