Adjust eventFilter to use new features
This commit is contained in:
parent
e56d33badc
commit
cd5f2562aa
@ -102,12 +102,29 @@ class ModeManager(QObject):
|
|||||||
self.entered.emit(mode)
|
self.entered.emit(mode)
|
||||||
|
|
||||||
def eventFilter(self, obj, evt):
|
def eventFilter(self, obj, evt):
|
||||||
if evt.type() not in [QEvent.KeyPress, QEvent.KeyRelease]:
|
"""Filter all events based on the currently set mode.
|
||||||
|
|
||||||
|
Also calls the real keypress handler.
|
||||||
|
"""
|
||||||
|
typ = evt.type()
|
||||||
|
handler = self._handlers[self.mode]
|
||||||
|
if typ not in [QEvent.KeyPress, QEvent.KeyRelease]:
|
||||||
|
# We're not interested in non-key-events so we pass them through.
|
||||||
return False
|
return False
|
||||||
elif self.mode == "insert":
|
elif self.mode in self._passthrough:
|
||||||
|
# We're currently in a passthrough mode so we pass everything
|
||||||
|
# through.*and* let the passthrough keyhandler know.
|
||||||
|
# FIXME what if we leave the passthrough mode right here?
|
||||||
|
if handler is not None:
|
||||||
|
handler(evt)
|
||||||
return False
|
return False
|
||||||
elif evt.type() == QEvent.KeyPress:
|
elif typ == QEvent.KeyPress:
|
||||||
self._handlers[self.mode](evt)
|
# KeyPress in a non-passthrough mode - call handler and filter
|
||||||
|
# event from widgets
|
||||||
|
if handler is not None:
|
||||||
|
handler(evt)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
# KeyRelease in a non-passthrough mode - filter event and ignore it
|
||||||
|
# entirely.
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user