Skip to main content

Module dom_events

Module dom_events 

Source
Expand description

Runtime event dispatch (phase 4): input messages -> DOM events -> propagation, one pass per event over every installed host. See dom_events::deliver_input_events. Runtime event dispatch for the dynamic DOM API (phase 4).

These systems turn the input pipeline’s typed messages (clicks, pointer moves, wheel, keys, focus changes, text commits, scroll) into DOM events and route each one through the capture -> target -> bubble propagation driver in crate::event, once, whatever the number of script hosts the app runs. A handler bound with n.on(type, handler) runs here, in the host that bound it or natively; commands it queues are forwarded onto the ScriptCommandEvent bus so the normal appliers pick them up.

The full event set: click, dblclick, pointerdown / pointerup / pointermove / pointerenter / pointerleave, wheel, keydown / keyup, input, change, focus, blur, submit, scroll.

Sources and current limitations:

  • Pointer events target the entity currently under the cursor (Hovered); pointerenter / pointerleave come from the hover marker transitions.
  • keydown targets the focused entity (from the input router’s FocusedKey); keyup targets the focused entity. With nothing focused both go to the document root, the way a browser sends them to the body, so a listener on the document hears app-wide shortcuts.
  • input fires per edit, from the TextEditApplied signal the text pipeline raises (or a page, whose fields the browser edits): one event per keystroke, paste, or IME commit that changes the text, at most one per entity per tick, carrying the field’s text after the edit. A pure caret move is not an edit and fires nothing.
  • change and submit fire on commit, from the input router’s TextInputCommitted signal; submit is the Enter-commit on a single-line input.
  • scroll comes from a changed scroll offset and does not bubble.

Default actions: only click (link navigation via <a href>) and submit (form submission) have one. prevent_default on a click records the target so the runtime’s anchor-navigation executor skips it; submit’s default is reserved (there is no form-submission model yet).

Structs§

EventHost
How the dispatch reaches one installed host: offer it a handler token, and forward the commands its handlers queued.
EventHosts
The hosts DOM events are delivered into, one entry per installed host. Empty for an app with no script: native (C-ABI and SDK) handlers still run.
PendingDomEvents
The DOM events read from this tick’s input, waiting for delivery.

Functions§

deliver_input_events
Deliver the pointer, click, wheel and key events read this tick.
deliver_state_events
Deliver the focus, hover, edit, commit and scroll events read this tick.
queue_pointer_and_key_events
Read this tick’s pointer, click, wheel and key input as DOM events, for deliver_input_events. Pointer events target the hovered entity; key events target the focused entity, or the document root when nothing is focused.
queue_state_events
Read this tick’s focus, hover, edit, commit and scroll changes as DOM events, for deliver_state_events.
register_dom_event_messages
Register every input message the DOM event queues read, where the world does not have it yet.
register_event_host
Put the host stored as the resource H on the list DOM events are delivered into.