Skip to content

Commit 6e35205

Browse files
[ui] Fix: Clear focus each time the mouseButton is pressed
1 parent d5007c6 commit 6e35205

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

meshroom/ui/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
import meshroom.ui.app
1111

1212
meshroom.ui.uiInstance = meshroom.ui.app.MeshroomApp(sys.argv)
13+
clearFocusEventFilter = meshroom.ui.app.ClearFocusEventFilter()
14+
meshroom.ui.uiInstance.installEventFilter(clearFocusEventFilter)
1315
meshroom.ui.uiInstance.exec()

meshroom/ui/app.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from PySide6 import __version__ as PySideVersion
88
from PySide6 import QtCore
9-
from PySide6.QtCore import QUrl, QJsonValue, qInstallMessageHandler, QtMsgType, QSettings
9+
from PySide6.QtCore import QUrl, QJsonValue, qInstallMessageHandler, QtMsgType, QSettings, QObject, QEvent
1010
from PySide6.QtGui import QIcon
1111
from PySide6.QtQml import QQmlDebuggingEnabler
1212
from PySide6.QtQuickControls2 import QQuickStyle
@@ -196,6 +196,21 @@ def createMeshroomParser(args):
196196
return parser.parse_args(args[1:])
197197

198198

199+
class ClearFocusEventFilter(QObject):
200+
""" Clear focus each time a mouse button is pressed
201+
"""
202+
203+
def eventFilter(self, watched: QObject, event: QtCore.QEvent) -> bool:
204+
205+
if event.type() != QEvent.MouseButtonPress:
206+
return False
207+
208+
focusObject = QApplication.focusObject()
209+
if hasattr(focusObject, "setFocus"):
210+
focusObject.setFocus(False)
211+
212+
return False
213+
199214
class MeshroomApp(QApplication):
200215
""" Meshroom UI Application. """
201216
def __init__(self, inputArgs):

meshroom/ui/qml/main.qml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,4 @@ ApplicationWindow {
184184
replaceExit: Transition {}
185185
}
186186

187-
background: MouseArea {
188-
onPressed: {
189-
forceActiveFocus();
190-
}
191-
}
192187
}

0 commit comments

Comments
 (0)