# GLMakie: Run a function when slider is released

**URL:** <https://discourse.julialang.org/t/glmakie-run-a-function-when-slider-is-released/103295>\
**Category:** Visualization\
**Created:** [August 28, 2023, 2:54pm UTC](https://discourse.julialang.org/t/glmakie-run-a-function-when-slider-is-released/103295 "2023-08-28T14:54:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![f.ij](https://avatars.discourse-cdn.com/v4/letter/f/8491ac/32.png) [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Post date:** [August 28, 2023, 2:54pm UTC](https://discourse.julialang.org/t/glmakie-run-a-function-when-slider-is-released/103295/1 "2023-08-28T14:54:04Z")

</div>

Quite a simple question: Is it possible to run a function specifically when a slider is released?

A way to check whether the slider is currently being dragged would suffice. I couldn’t find a way to do this.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [August 28, 2023, 4:40pm UTC](https://discourse.julialang.org/t/glmakie-run-a-function-when-slider-is-released/103295/2 "2023-08-28T16:40:17Z")

</div>

I think it should be possible.

Looking at [here](https://github.com/MakieOrg/Makie.jl/blob/master/src/makielayout/blocks/slider.jl) we have the function `initialize_block!` for a `Slider`, which seems to do the setup.

There are some functions like `onmouseleftXXX` which seems like what we would want, and we could define the same mouseevent they use there for `onmouseleftup`.

So I think something along the way

```julia
...
sl = Slider(...)
mouseevents = addmouseevents!(sl.blockscene, sl.layoutobservables.computedbbox)
onmouseleftup(mouseevents) do event
    # Your mouse release code
end

```

should work, though for me this didn’t seem to get all the way. Have to run now, so thought I would just put it here if someone wanted to look into it further.

---

<div class="post-metadata">

**Author:** ![f.ij](https://avatars.discourse-cdn.com/v4/letter/f/8491ac/32.png) [@f.ij](https://discourse.julialang.org/u/f.ij)\
**Post date:** [September 2, 2023, 1:07pm UTC](https://discourse.julialang.org/t/glmakie-run-a-function-when-slider-is-released/103295/3 "2023-09-02T13:07:30Z")

</div>

Thanks for the answer. I also cannot get this to work as intended. It seems to only work when the scene is clicked and released without being dragged. I also tried `onmouseleftdragstop` but I can only get this to work very unreliable, I don’t really understand when it works.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [September 2, 2023, 2:46pm UTC](https://discourse.julialang.org/t/glmakie-run-a-function-when-slider-is-released/103295/4 "2023-09-02T14:46:06Z")

</div>

There’s this open PR for it [Add option to update when releasing mouse button from slide by lwhitefox · Pull Request #2228 · MakieOrg/Makie.jl · GitHub](https://github.com/MakieOrg/Makie.jl/pull/2228)
