Skip to main content

dispatch_scroll

Function dispatch_scroll 

Source
pub fn dispatch_scroll(
    stack: &ModalStack,
    scroll_surfaces: &[ScrollSurface],
    position: Point,
    delta: ScrollDelta,
) -> Vec<UiEvent>
Expand description

Translate a raw scroll-wheel event into a Vec<UiEvent>, consulting the modal stack first, then the registered scroll surfaces.

§Scroll delta sign convention

Positive delta.y = scroll content up (toward the top of the document). Backends normalise their native direction before constructing ScrollDelta — see ScrollDelta for the canonical definition. Compose helpers ([TreeController], [SidebarSystem]) consume the delta directly without per-call-site negation.

§Returns

Three cases:

  1. Scroll landed inside an open modal. Emits [UiEvent::Scroll { widget: Some(modal_id), delta, position }]. The app routes to the modal’s inner scroll handler.
  2. Modal(s) open but scroll was outside them. Emits nothing — scroll behind an open modal is swallowed (you can’t scroll the editor while a dialog is up).
  3. No modal open. Hit-tests scroll_surfaces last-to-first (topmost-painted wins). If a surface matches, emits [UiEvent::Scroll { widget: Some(surface_id), delta, position }]. If no surface matches, emits [UiEvent::Scroll { widget: None, delta, position }] for base-layer handling.