How to add replay button?
9 views (last 30 days)
Here I am enclosing the .m file, in which I have created a play button i.e auto scroll of the Slider with images and Stop Button as well . But I wanted to create a button to replay button which can play the slider again. Is there any way for this?
Voss on 10 Jun 2022
Edited: Voss on 10 Jun 2022
Create a new button:
h.replaybutton = uicontrol( ...
'Position',[0.8 0 0.1 0.1], ...
'BackgroundColor',[1 1 1], ...
In its callback function, reset the slider Value to the Min, and then execute the Play button callback:
That should give you "replay" functionality.
By the way, this
if sliderValue < (get(h.slider, 'Max') - get(h.slider, 'Min'))
should be this
if sliderValue < get(h.slider, 'Max')
Otherwise, the montages stop when N=99 instead of N=100.
Maybe you had it like that at one point but had a problem when the slider's Value was its Max. That happened because the Value was not exactly an integer, which can happen because of floating-point precision or because the user has interacted with the slider directly. In any case, you can avoid that problem by rounding the slider Value when you set it:
set(h.slider, 'Value', round(sliderValue + 1));
and you may want to change the slider's SliderStep to control how the Value changes when the user clicks it.