mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Allow scripts to override the navigation focus state set by QML dialogs
This commit is contained in:
parent
cdffb453c6
commit
882139ebcf
3 changed files with 20 additions and 2 deletions
|
@ -4705,6 +4705,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
|
||||
RayToOverlayIntersectionResultFromScriptValue);
|
||||
|
||||
scriptEngine->registerGlobalObject("OffscreenFlags", DependencyManager::get<OffscreenUi>()->getFlags());
|
||||
scriptEngine->registerGlobalObject("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data());
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ class OffscreenFlags : public QObject {
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(bool navigationFocused READ isNavigationFocused WRITE setNavigationFocused NOTIFY navigationFocusedChanged)
|
||||
|
||||
// Allow scripts that are doing their own navigation support to disable navigation focus (i.e. handControllerPointer.js)
|
||||
Q_PROPERTY(bool navigationFocusDisabled READ isNavigationFocusDisabled WRITE setNavigationFocusDisabled NOTIFY navigationFocusDisabledChanged)
|
||||
|
||||
public:
|
||||
|
||||
OffscreenFlags(QObject* parent = nullptr) : QObject(parent) {}
|
||||
|
@ -40,11 +43,21 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool isNavigationFocusDisabled() const { return _navigationFocusDisabled; }
|
||||
void setNavigationFocusDisabled(bool disabled) {
|
||||
if (_navigationFocusDisabled != disabled) {
|
||||
_navigationFocusDisabled = disabled;
|
||||
emit navigationFocusDisabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
void navigationFocusedChanged();
|
||||
void navigationFocusDisabledChanged();
|
||||
|
||||
private:
|
||||
bool _navigationFocused { false };
|
||||
bool _navigationFocusDisabled{ false };
|
||||
};
|
||||
|
||||
QString fixupHifiUrl(const QString& urlString) {
|
||||
|
@ -103,6 +116,10 @@ bool OffscreenUi::shouldSwallowShortcut(QEvent* event) {
|
|||
OffscreenUi::OffscreenUi() {
|
||||
}
|
||||
|
||||
QObject* OffscreenUi::getFlags() {
|
||||
return offscreenFlags;
|
||||
}
|
||||
|
||||
void OffscreenUi::create(QOpenGLContext* context) {
|
||||
OffscreenQmlSurface::create(context);
|
||||
auto rootContext = getRootContext();
|
||||
|
@ -392,7 +409,7 @@ QVariant OffscreenUi::waitForInputDialogResult(QQuickItem* inputDialog) {
|
|||
}
|
||||
|
||||
bool OffscreenUi::navigationFocused() {
|
||||
return offscreenFlags->isNavigationFocused();
|
||||
return !offscreenFlags->isNavigationFocusDisabled() && offscreenFlags->isNavigationFocused();
|
||||
}
|
||||
|
||||
void OffscreenUi::setNavigationFocused(bool focused) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
||||
void addMenuInitializer(std::function<void(VrMenu*)> f);
|
||||
|
||||
QObject* getFlags();
|
||||
QQuickItem* getDesktop();
|
||||
QQuickItem* getToolWindow();
|
||||
|
||||
|
|
Loading…
Reference in a new issue