Effacer les filtres
Effacer les filtres

How to enable "Snap to Tick" for a slider in App Designer?

24 vues (au cours des 30 derniers jours)
Farzam Malmir
Farzam Malmir le 21 Fév 2019
Commenté : Jesse Beaupre le 15 Juin 2023
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
Farzam Malmir
Farzam Malmir le 22 Fév 2019
In the same slider you posted, for example I want the slider handle sits on the tick intervals not between them. for example I want 1, 2, 3 ... rather than 1.48
Jesse Beaupre
Jesse Beaupre le 15 Juin 2023
In the callback make the slider value rounded and then set the slider position to this rounded value.

Connectez-vous pour commenter.

Réponses (1)

Kevin Chng
Kevin Chng le 22 Fév 2019
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
  3 commentaires
Kevin Chng
Kevin Chng le 25 Fév 2019
Modifié(e) : Kevin Chng le 25 Fév 2019
The only way i can think about it is to create a callback function, then use the round off method to readjust the value of slider if user move the handle to the place between intervals.
Create a callback function for your slider
value = app.Slider.Value;
app.Slider.Value=round( value / 20 ) * 20;
You may change the value of 20 to 2, if the interval is 2.
Jeff Severino
Jeff Severino le 2 Juil 2019
clever!

Connectez-vous pour commenter.

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!

Translated by