Skip to main content

render

Function render 

Source
pub fn render<V: 'static>(
    id: impl Into<ElementId>,
    doc: &Doc,
    layouts: &BlockLayouts,
    selection: Option<Selection>,
    dragging: bool,
    window: &mut Window,
    cx: &mut Context<'_, V>,
    on_pointer: impl Fn(&mut V, Pointer, &mut Context<'_, V>) + 'static,
) -> AnyElement
Expand description

Render doc with selection painted in it, reporting what the pointer does.

dragging is the caller’s: a move only extends a selection that a press started, and which item that press landed in is not something one block of text can know. It has to be true for at most one block at a time — a block that is told it is dragging follows the pointer over the whole window, so two of them would both extend on every move.

Releasing is answered twice over — on the text and off it — because a drag that ends past the edge of a paragraph is the ordinary way to select to the end of one. Moves are read the same way: on_mouse_move is delivered only while the pointer is over this element’s hitbox, so a drag off the text — or under something painted over it — would otherwise stop extending where it crossed the edge. BlockLayouts::hit resolves a point outside the text to the nearest line, which is what makes the off-hitbox move answerable at all.