Handling of user inputs
Some widgets are interactive and react to input events. Frameworks use the widget tree to determine which widgets have been hit by a pointer through a process called hit testing. Frameworks dispatch events directly or propagate them along the tree. In the direct dispatch approach, the framework sends the events to either the innermost interactive widget under the pointer or the focused widget for keyboard events. In the propagation approach the events travels downward from the root to the innermost widget and then travel backward. Flutter and Qt use a hybrid approach that uses a direct dispatch approach, but allow explicit event propagation upward. We use a direct dispatch approach and do not offer any way of escaping this behavior for now. Thus, a widget that reacts to an event will always consume that event.
Frameworks use either a callback-based approach or an event-based approach to handle widget reactions. In a callback-based approach the application and the framework registers callbacks to call when the widget reacts to an event. In an event-based approach widget emits their own events that are dispatched to a centralized handler or to dedicated handlers. Modern frameworks usually use the callback-based approach because it is well suited to declarative user interfaces. The event-based approach allows a better decoupling between the user interface and the application, which improves testability. This is why we choose the event-based approach. However, we haven’t ruled out using a callback-based approach on the user side. A declarative user interface can easily be converted to an event-based approach following a compilation step.