diff --git a/meshroom/ui/__main__.py b/meshroom/ui/__main__.py index 9c75e6ecbd..0a9f8d6666 100644 --- a/meshroom/ui/__main__.py +++ b/meshroom/ui/__main__.py @@ -10,4 +10,6 @@ import meshroom.ui.app meshroom.ui.uiInstance = meshroom.ui.app.MeshroomApp(sys.argv) +clearFocusEventFilter = meshroom.ui.app.ClearFocusEventFilter() +meshroom.ui.uiInstance.installEventFilter(clearFocusEventFilter) meshroom.ui.uiInstance.exec() diff --git a/meshroom/ui/app.py b/meshroom/ui/app.py index e83c90e52b..a39b2ec965 100644 --- a/meshroom/ui/app.py +++ b/meshroom/ui/app.py @@ -6,7 +6,7 @@ from PySide6 import __version__ as PySideVersion from PySide6 import QtCore -from PySide6.QtCore import QUrl, QJsonValue, qInstallMessageHandler, QtMsgType, QSettings +from PySide6.QtCore import QUrl, QJsonValue, qInstallMessageHandler, QtMsgType, QSettings, QObject, QEvent from PySide6.QtGui import QIcon from PySide6.QtQml import QQmlDebuggingEnabler from PySide6.QtQuickControls2 import QQuickStyle @@ -196,6 +196,21 @@ def createMeshroomParser(args): return parser.parse_args(args[1:]) +class ClearFocusEventFilter(QObject): + """ Clear focus each time a mouse button is pressed + """ + + def eventFilter(self, watched: QObject, event: QtCore.QEvent) -> bool: + + if event.type() != QEvent.MouseButtonPress: + return False + + focusObject = QApplication.focusObject() + if hasattr(focusObject, "setFocus"): + focusObject.setFocus(False) + + return False + class MeshroomApp(QApplication): """ Meshroom UI Application. """ def __init__(self, inputArgs): diff --git a/meshroom/ui/qml/main.qml b/meshroom/ui/qml/main.qml index 20c2f81fa1..9af09064df 100644 --- a/meshroom/ui/qml/main.qml +++ b/meshroom/ui/qml/main.qml @@ -184,9 +184,4 @@ ApplicationWindow { replaceExit: Transition {} } - background: MouseArea { - onPressed: { - forceActiveFocus(); - } - } }