mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Raise and lower keyboard for HTML fields in Marketplace window
This commit is contained in:
parent
875566d956
commit
2344d15dbc
3 changed files with 44 additions and 1 deletions
|
@ -66,6 +66,24 @@ Windows.ScrollingWindow {
|
|||
anchors.fill: parent
|
||||
focus: true
|
||||
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 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,29 @@ void QmlWebWindowClass::emitWebEvent(const QVariant& webMessage) {
|
|||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "emitWebEvent", Qt::QueuedConnection, Q_ARG(QVariant, webMessage));
|
||||
} else {
|
||||
emit webEventReceived(webMessage);
|
||||
// Special cases for raising and lowering the virtual keyboard.
|
||||
if (webMessage.type() == QVariant::String && webMessage.toString() == "_RAISE_KEYBOARD") {
|
||||
setKeyboardRaised(asQuickItem(), true);
|
||||
} else if (webMessage.type() == QVariant::String && webMessage.toString() == "_LOWER_KEYBOARD") {
|
||||
setKeyboardRaised(asQuickItem(), false);
|
||||
} else {
|
||||
emit webEventReceived(webMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QmlWebWindowClass::setKeyboardRaised(QObject* object, bool raised) {
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
QQuickItem* item = dynamic_cast<QQuickItem*>(object);
|
||||
while (item) {
|
||||
if (item->property("keyboardRaised").isValid()) {
|
||||
item->setProperty("keyboardRaised", QVariant(raised));
|
||||
return;
|
||||
}
|
||||
item = dynamic_cast<QQuickItem*>(item->parentItem());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ signals:
|
|||
|
||||
protected:
|
||||
QString qmlSource() const override { return "QmlWebWindow.qml"; }
|
||||
|
||||
private:
|
||||
void setKeyboardRaised(QObject* object, bool raised);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue