Skip to main content

surface_input

Function surface_input 

Source
pub fn surface_input<E>(
    element: E,
    handler: impl Fn(SurfaceInput) + 'static,
) -> impl IntoElement
where E: InteractiveElement + Element<PrepaintState = Option<Hitbox>> + 'static,
Expand description

Wrap element so a producer receives its input through SurfaceInput.

element is the surface’s own element — a gpu_canvas — and handler is called with every pointer event routed to it, in surface-local physical pixels. The window is marked for redraw after each event, since a surface that handled input has almost certainly changed what it draws.

The element keeps the sizing, styling and painting it had; the gateway adds the input subscription, reads the element’s bounds from its own prepaint so the producer’s coordinates are surface-local without the caller plumbing them, and names the element if the caller did not (the drag model needs an id — see the module docs).