Showing the changes to interface/src/ui/InteractiveWindow.cpp (1 of 3 files). Show all
Unified · Split
| @@ -68,6 +68,16 @@ void interactiveWindowPointerFromScriptValue(const QScriptValue& object, Interac · 67 unmodified lines | ||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | +void InteractiveWindow::forwardKeyPressEvent(int key, int modifiers) { | |
| 72 | + QKeyEvent* event = new QKeyEvent(QEvent::KeyPress, key, static_cast<Qt::KeyboardModifiers>(modifiers)); | |
| 73 | + QCoreApplication::postEvent(QCoreApplication::instance(), event); | |
| 74 | +} | |
| 75 | + | |
| 76 | +void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) { | |
| 77 | + QKeyEvent* event = new QKeyEvent(QEvent::KeyRelease, key, static_cast<Qt::KeyboardModifiers>(modifiers)); | |
| 78 | + QCoreApplication::postEvent(QCoreApplication::instance(), event); | |
| 79 | +} | |
| 80 | + | |
| 71 | 81 | /**jsdoc |
| 72 | 82 | * A set of properties used when creating an <code>InteractiveWindow</code>. |
| 73 | 83 | * @typedef {object} InteractiveWindow.Properties |
| @@ -152,12 +162,16 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 78 unmodified lines | ||
| 152 | 162 | _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, this); |
| 153 | 163 | QObject::connect(rootItem, SIGNAL(sendToScript(QVariant)), this, SLOT(qmlToScript(const QVariant&)), |
| 154 | 164 | Qt::QueuedConnection); |
| 165 | + QObject::connect(rootItem, SIGNAL(keyPressEvent(int, int)), this, SLOT(forwardKeyPressEvent(int, int)), | |
| 166 | + Qt::QueuedConnection); | |
| 167 | + QObject::connect(rootItem, SIGNAL(keyReleaseEvent(int, int)), this, SLOT(forwardKeyReleaseEvent(int, int)), | |
| 168 | + Qt::QueuedConnection); | |
| 155 | 169 | emit mainWindow->windowGeometryChanged(qApp->getWindow()->geometry()); |
| 156 | 170 | } |
| 157 | 171 | }); |
| 172 | + | |
| 158 | 173 | _dockWidget->setSource(QUrl(sourceUrl)); |
| 159 | 174 | |
| 160 | − | |
| 161 | 175 | mainWindow->addDockWidget(dockArea, _dockWidget.get()); |
| 162 | 176 | } else { |
| 163 | 177 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |