Skip to main content

SliderModifiers

Trait SliderModifiers 

Source
pub trait SliderModifiers: Sized {
    // Required methods
    fn on_change<F>(self, callback: F) -> Self
       where F: 'static + Fn(&mut EventContext<'_>, f32);
    fn range<U: Into<Range<f32>> + Clone + 'static>(
        self,
        range: impl Res<U> + 'static,
    ) -> Self;
    fn vertical<U: Into<bool> + Clone + 'static>(
        self,
        vertical: impl Res<U> + 'static,
    ) -> Self;
    fn step<U: Into<f32> + Clone + 'static>(
        self,
        step: impl Res<U> + 'static,
    ) -> Self;
    fn default_value<U: Into<f32> + Clone + 'static>(
        self,
        default_value: impl Res<U> + 'static,
    ) -> Self;
}

Required Methods§

Source

fn on_change<F>(self, callback: F) -> Self
where F: 'static + Fn(&mut EventContext<'_>, f32),

Sets the callback triggered when the slider value is changed.

Takes a closure which triggers when the slider value is changed, either by pressing the track or dragging the thumb along the track.


Slider::new(cx, value)
    .on_change(|cx, value| {
        let _ = (cx, value);
    });
Source

fn range<U: Into<Range<f32>> + Clone + 'static>( self, range: impl Res<U> + 'static, ) -> Self

Sets the range of the slider.

If the source value is outside of the range then the slider will clip to min/max of the range.


Slider::new(cx, value)
    .range(-20.0..50.0)
    .on_change(|cx, value| {
        let _ = (cx, value);
    });
Source

fn vertical<U: Into<bool> + Clone + 'static>( self, vertical: impl Res<U> + 'static, ) -> Self

Sets the orientation of the slider to vertical.


Slider::new(cx, value)
    .vertical(true)
    .on_change(|cx, value| {
        let _ = (cx, value);
    });
Source

fn step<U: Into<f32> + Clone + 'static>( self, step: impl Res<U> + 'static, ) -> Self

Set the step value for the slider.


Slider::new(cx, value)
    .step(0.1_f32)
    .on_change(|cx, value| {
        let _ = (cx, value);
    });
Source

fn default_value<U: Into<f32> + Clone + 'static>( self, default_value: impl Res<U> + 'static, ) -> Self

Sets the value that the slider resets to when the thumb is double-clicked.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S> SliderModifiers for Handle<'_, Slider<S>>
where S: SignalGet<f32> + 'static,