Hi, there.
Here is a change set that adds event filters to Squeak: event-filters.cs http://forum.world.st/file/n4895521/event-filters.cs
It is implemented like event listeners but with a spearation between global event filters in the HandMorph and local event filters in any other Morph.
Both event filters and event listeners do only work on event copies to not interfere with regular event dispatching. Such bugs would be quite challenging to hunt down.
Here is a usage example:
m := ActiveWorld submorphs third. "some system window" filter := PluggableEventFilter new on: [:evt :target | Transcript showln: evt printString. false].
m addEventFilter: filter.
m removeEventFilter: filter. m addKeyboardFilter: filter.
Just like event listeners, there are generic event filters, mouse event filters, and keyboard event filters. All filter objects are weakly referenced - just like event filters.
Where to use event filters? - Processing global keyboard shortcuts and avoiding some other Morph to handle the same key - Temporarily disable specific events for a morph from the outside
The general idea is based on the Qt framework: http://doc.qt.io/qt-5/eventsandfilters.html#event-filters
Do we want that in the Trunk?
Best, Marcel
-- View this message in context: http://forum.world.st/Event-filters-for-user-input-events-i-e-mouse-clicks-e... Sent from the Squeak - Dev mailing list archive at Nabble.com.