diff --git a/interface/src/scripting/DesktopScriptingInterface.cpp b/interface/src/scripting/DesktopScriptingInterface.cpp index ffa63ea670..f7ac8f43c9 100644 --- a/interface/src/scripting/DesktopScriptingInterface.cpp +++ b/interface/src/scripting/DesktopScriptingInterface.cpp @@ -60,7 +60,9 @@ static const QVariantMap RELATIVE_POSITION_ANCHOR { }; DesktopScriptingInterface::DesktopScriptingInterface(QObject* parent, bool restricted) - : QObject(parent), _restricted(restricted) { } + : QObject(parent), _restricted(restricted) { + connect(this, &DesktopScriptingInterface::uiFocusChanged, [this] (bool isActive) { _isOverlayWindowFocused = isActive; }); +} int DesktopScriptingInterface::getWidth() { QSize size = qApp->getWindow()->windowHandle()->screen()->virtualSize(); diff --git a/interface/src/scripting/DesktopScriptingInterface.h b/interface/src/scripting/DesktopScriptingInterface.h index db52906cfd..41a2c51ac9 100644 --- a/interface/src/scripting/DesktopScriptingInterface.h +++ b/interface/src/scripting/DesktopScriptingInterface.h @@ -104,6 +104,13 @@ public: int getWidth(); int getHeight(); + /*@jsdoc + * Checks whether the keyboard focus belongs to overlay UI window. + * @function Desktop.isOverlayWindowFocused + * @returns {boolean} true if the keyboard focus is on overlay UI window, false if not. + */ + Q_INVOKABLE bool isOverlayWindowFocused() { return _isOverlayWindowFocused; }; + signals: /*@jsdoc @@ -124,6 +131,7 @@ private: static QVariantMap getRelativePositionAnchor(); Q_INVOKABLE static QVariantMap getPresentationMode(); const bool _restricted; + std::atomic _isOverlayWindowFocused { false }; };