Open padraic-shafer opened 1 month ago
Here the PassThroughEventFilter
helper class is defined with an eventFilter()
method that runs a matching event handler and then sends the event to the filter of the parent QObject
.
If a handler has been registeredduring PassThroughEventFilter
initialization for the type of event being processed, then it will be called. Otherwise a 'no-op' handler is called.
Here is an example of an event handler being registered by the connect_model_slots()
method of the QTiledCatalogSelectorDialog
widget.
urlFocusInFilter
object -- an instance of the PassThroughEventFilter
class -- by passing a dictionary with a single event handler (model.on_url_focus_in_event
) as the value associated the QEvent.Type
key (QEvent.Type.FocusIn
).url_entry
(self.url_entry.installEventFilter(urlFocusInFilter)
).url_entry
widget receives focus, the registered event handler from the model will now be called.Finally, here is an example of a simple event handler that responds to the FocusIn
event, that is described above.
In the major refactoring that is expected to happen during the early stages of our https://github.com/NSLS2/pymca/milestone/1 work, some code examples might get lost from the active branch.
Here, I'm documenting the idea of using a
PassThroughEventFilter
helper class to simplify adding non-consuming event filters from a view model to a view widget. This is extracted from commit f0b87e5 .