![slider.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205312/slider.png)
How to enable "Snap to Tick" for a slider in App Designer?
21 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I want to know how to make a slider move discretely rather than continuously. As an example, I want the slider to jump from 1 to 2 when I move it. In other words, I need to enable the "Snap to Tick" feature.
Thanks in advance.
3 commentaires
Jesse Beaupre
le 15 Juin 2023
In the callback make the slider value rounded and then set the slider position to this rounded value.
Réponses (1)
Kevin Chng
le 22 Fév 2019
![Untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205320/Untitled.png)
Is it what you expect? If you are using app designer, on your left hand side bottom, there is configuration you may edit. Empty the minor tick, and modify the major tick to 1,2,3,4,5.
Don't forgot to change the limit as well to 0,5
4 commentaires
Fryderyk Kukowski
le 11 Août 2024 à 12:09
@Kevin Chng It does not work.
My slider settings:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1750714/image.png)
I have set up slider functions like this:
function SliderValueChanging(app, event)
app.Slider.Value = round(event.Value);
end
function SliderValueChanged(app, event)
app.Slider.Value = round(app.Slider.Value);
end
But the slider behaves like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1750719/image.gif)
So the SliderValueChanging has no effect.
Is there a way to fix this?
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!