History

Implement BUGZ-226: Forward keypresses made while Top Bar is in focus

Zach Fox committed 7 years ago

Commit 9a926ab1 parent 2b90d843 files · +29 −2Browse files

Showing the changes to interface/src/ui/InteractiveWindow.cpp (1 of 3 files). Show all

Unified · Split

interface/src/ui/InteractiveWindow.cpp+15−1
@@ -68,6 +68,16 @@ void interactiveWindowPointerFromScriptValue(const QScriptValue& object, Interac · 67 unmodified lines
68 }68 }
69}69}
70 70
71void 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
76void 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/**jsdoc81/**jsdoc
72 * A set of properties used when creating an <code>InteractiveWindow</code>.82 * A set of properties used when creating an <code>InteractiveWindow</code>.
73 * @typedef {object} InteractiveWindow.Properties83 * @typedef {object} InteractiveWindow.Properties
@@ -152,12 +162,16 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 78 unmodified lines
152 _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, this);162 _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, this);
153 QObject::connect(rootItem, SIGNAL(sendToScript(QVariant)), this, SLOT(qmlToScript(const QVariant&)),163 QObject::connect(rootItem, SIGNAL(sendToScript(QVariant)), this, SLOT(qmlToScript(const QVariant&)),
154 Qt::QueuedConnection);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 emit mainWindow->windowGeometryChanged(qApp->getWindow()->geometry());169 emit mainWindow->windowGeometryChanged(qApp->getWindow()->geometry());
156 }170 }
157 });171 });
172
158 _dockWidget->setSource(QUrl(sourceUrl));173 _dockWidget->setSource(QUrl(sourceUrl));
159 174
160
161 mainWindow->addDockWidget(dockArea, _dockWidget.get());175 mainWindow->addDockWidget(dockArea, _dockWidget.get());
162 } else {176 } else {
163 auto offscreenUi = DependencyManager::get<OffscreenUi>();177 auto offscreenUi = DependencyManager::get<OffscreenUi>();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t