Module kas::event

source ·
Expand description

Event handling

Event handling model

Note: widgets are represented as an acyclic tree, with the root at the “top” of the tree. Each tree node is a Widget and has an Id. An Id represents a path and may be used to find the most direct root from the root to the target.

An Event is sent to a target widget as follows:

  1. Determine the target’s Id. For example, this may be the nav_focus or may be determined from from mouse/touch coordinates by calling find_id.

  2. If the target is disabled, then find the top-most ancestor which is disabled and make that the target, but inhibit calling of Events::handle_event on this widget (but still unwind, calling Events::handle_event on ancestors)).

  3. Traverse down the widget tree from its root to the target according to the Id. On each node (excluding the target),

  4. In the normal case (when the target is not disabled and the event is not stolen), Events::handle_event is called on the target.

  5. If the message stack is not empty, call Events::handle_messages on the current node.

  6. Unwind, traversing back up the widget tree (towards the root). On each node (excluding the target),

  7. If the message stack is not empty, call AppData::handle_messages.

  8. Clear any messages still on the message stack, printing a warning to the log. Messages should be handled during unwinding, though not doing so is safe (and possibly useful during development).

Pop-ups

When a pop-up widget is created, the pop-up’s parent takes priority for “press” (mouse / touch) input as well as receiving keyboard focus.

If this input is unhandled, the pop-up is automatically closed and the event is re-sent to the next candidate, allowing handling of e.g. mouse clicks on widgets under a menu. This should be intuitive: UI which is in focus and not greyed-out should be interactive.

Modules

Structs

Enums