We want to move away from implementing widget behaviors in event handlers all over the place, and instead move to a model where behaviors can be added to a widget as separate objects. This model is already used in clutter, where the ClutterAction objects play the role of event controllers.
Typical examples of behaviors that might be encased in an event controller:
- double click
- right click
- click and drag
- long press
- horizontal swipe
These examples show that event controllers need to monitor the stream of input events, and match certain sequences of events. It is also evident that there may be multiple event controllers that are in various stages of recognizing an event stream as them as 'their own' at any given time. Therefore, events need to be passed to all event controllers, and can generally not be consumed early.
Once an event controller 'claims' a sequence, all the other controllers need to be informed that they should drop their in-flight recognitions for the involved events.
It is also possible that the same controller may recognize 2 streams of events at the same time, e.g. there might be two pinches going on a the same time (with the left and right hand). Therefore, the controllers need to keep the state for their current matches in separate objects (we still need to find a good name for them, maybe 'gesture' or 'event sequence' ?).
Event controllers will be attached to render objects, so behaviors can be restricted to subareas of a widget (initially, we may just attach event controllers to widgets, since we don't have render objects yet).
For some gestures like press-and-hold, it may be expected to display some feedback while it is being recognized, so event controllers will have to emit some signals during the recognition.
One thing to keep in mind while designing the event controllers is that some platforms (OS X, maybe utouch) provide events for gestures that have been recognized by a 'system recognizer'. We may want to offer a way to let a (possibly platform-specific) event controller handle these already recognized gestures.
Could the name of this object be improved, it should at least not appear in the public API for someone that needs to listen to a event -- JohanDahlin
the idea is that you should be able to implement an "event controller" (or "event recognizer", or "Bob") for custom gestures, so it has to be public; there should be ready-made objects available to application developers to be added to widgets. -- EmmanueleBassi