diff --git a/docs/src/content/docs/components/slider.mdx b/docs/src/content/docs/components/slider.mdx index 755a695..3476336 100644 --- a/docs/src/content/docs/components/slider.mdx +++ b/docs/src/content/docs/components/slider.mdx @@ -52,3 +52,8 @@ The minimum value of the slider. The current value of the slider. + +## Callbacks + +### released(value: float) +Invoked when the slider is released. diff --git a/ui/components/slider.slint b/ui/components/slider.slint index 032f355..b2dccfc 100644 --- a/ui/components/slider.slint +++ b/ui/components/slider.slint @@ -12,6 +12,8 @@ export component Slider { in property divisions: 0; in property maximum: 100; + callback released(value: float); + property steps: root.divisions > 0 ? (root.maximum - root.minimum) / root.divisions : 1; min_height: 20px; @@ -76,6 +78,12 @@ export component Slider { moved => { root.set_value(root.length_to_value(state_layer.x + self.x + self.mouse_x, track.width)); } + + pointer-event(event) => { + if event.kind == PointerEventKind.up { + root.released(root.value); + } + } } }