mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #15731 from zfox23/SUI/forwardKeyEvents
Implement BUGZ-226: Forward keypresses made while Top Bar is in focus
This commit is contained in:
commit
b62ab2ea82
3 changed files with 29 additions and 2 deletions
|
@ -18,6 +18,16 @@ import "qrc:////qml//hifi//models" as HifiModels // Absolute path so the same c
|
|||
|
||||
Rectangle {
|
||||
id: root
|
||||
focus: true
|
||||
|
||||
signal keyPressEvent(int key, int modifiers)
|
||||
Keys.onPressed: {
|
||||
keyPressEvent(event.key, event.modifiers);
|
||||
}
|
||||
signal keyReleaseEvent(int key, int modifiers)
|
||||
Keys.onReleased: {
|
||||
keyReleaseEvent(event.key, event.modifiers);
|
||||
}
|
||||
|
||||
SimplifiedConstants.SimplifiedConstants {
|
||||
id: simplifiedUI
|
||||
|
@ -455,5 +465,5 @@ Rectangle {
|
|||
break;
|
||||
}
|
||||
}
|
||||
signal sendToScript(var message);
|
||||
signal sendToScript(var message)
|
||||
}
|
||||
|
|
|
@ -68,6 +68,16 @@ void interactiveWindowPointerFromScriptValue(const QScriptValue& object, Interac
|
|||
}
|
||||
}
|
||||
|
||||
void InteractiveWindow::forwardKeyPressEvent(int key, int modifiers) {
|
||||
QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, static_cast<Qt::KeyboardModifiers>(modifiers));
|
||||
QCoreApplication::postEvent(QCoreApplication::instance(), event);
|
||||
}
|
||||
|
||||
void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) {
|
||||
QKeyEvent* event = new QKeyEvent(QEvent::KeyRelease, key, static_cast<Qt::KeyboardModifiers>(modifiers));
|
||||
QCoreApplication::postEvent(QCoreApplication::instance(), event);
|
||||
}
|
||||
|
||||
/**jsdoc
|
||||
* A set of properties used when creating an <code>InteractiveWindow</code>.
|
||||
* @typedef {object} InteractiveWindow.Properties
|
||||
|
@ -152,12 +162,16 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
|||
_dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, this);
|
||||
QObject::connect(rootItem, SIGNAL(sendToScript(QVariant)), this, SLOT(qmlToScript(const QVariant&)),
|
||||
Qt::QueuedConnection);
|
||||
QObject::connect(rootItem, SIGNAL(keyPressEvent(int, int)), this, SLOT(forwardKeyPressEvent(int, int)),
|
||||
Qt::QueuedConnection);
|
||||
QObject::connect(rootItem, SIGNAL(keyReleaseEvent(int, int)), this, SLOT(forwardKeyReleaseEvent(int, int)),
|
||||
Qt::QueuedConnection);
|
||||
emit mainWindow->windowGeometryChanged(qApp->getWindow()->geometry());
|
||||
}
|
||||
});
|
||||
|
||||
_dockWidget->setSource(QUrl(sourceUrl));
|
||||
|
||||
|
||||
mainWindow->addDockWidget(dockArea, _dockWidget.get());
|
||||
} else {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
|
|
|
@ -287,6 +287,9 @@ protected slots:
|
|||
*/
|
||||
void qmlToScript(const QVariant& message);
|
||||
|
||||
void forwardKeyPressEvent(int key, int modifiers);
|
||||
void forwardKeyReleaseEvent(int key, int modifiers);
|
||||
|
||||
private:
|
||||
QPointer<QObject> _qmlWindow;
|
||||
std::shared_ptr<DockWidget> _dockWidget { nullptr };
|
||||
|
|
Loading…
Reference in a new issue