Skip to main content

set_slider_on_drag

Function set_slider_on_drag 

Source
pub fn set_slider_on_drag(
    drags: MessageReader<'_, '_, DragMoveEvent>,
    q: Query<'_, '_, (&mut SliderValue, &Transform, Option<&KnobGeometry>)>,
    parents: Query<'_, '_, &ChildOf>,
    out: MessageWriter<'_, SliderChanged>,
)
Expand description

While the user drags a slider, continuously update its value based on the cursor x within the track. Reuses DragMoveEvent, so the slider inherits all of lumen-input’s per-OS drag-threshold behavior for free. Drags that started on the SliderThumb child (the common grab) resolve to the parent slider (see [resolve_control]).

Snapped through SliderValue::snap for the same reason a click is: a drag ends on a position the keyboard could have reached, so the thumb steps between stops rather than sliding freely.