Why slider is not working in my GUI?

25 views (last 30 days)
I have created a GUI consisted of 4 axes, a push button and a slider. Although, the slider commands (callbacks, uicontrols, guidata etc) including the mouseScroll function, are perfectly working, because they have been tested to a different figure (not my GUI) consisted of a single hFig and an axes1 and it perfectly work, but when I try to implement the same commands to my GUI it fails.
You will notice to the m files I attach, that I have placed the same commands over and over again to almost all the relative callback functions (slider1_Callback, mouseScroll, loadButton, etc) because they were asking for the variables to be stated.
Any help on this?
  1 Comment
Stelios Fanourakis
Stelios Fanourakis on 10 Jun 2018
The slider is not working. It won't move either under wheel scrolling or arrowheads pressing. If it slightly moves, it goes back to the beggining instantly and it won't control the image depicted on the first axes1, it won't alter.

Sign in to comment.

Accepted Answer

Jan
Jan on 11 Jun 2018
You are creating a new slider inside the callback of the slider:
handles.SliderFrame = uicontrol('Style','slider','Position',[60 20 400 50], ...
'Min',1,'Max',NumFrames,'Value',1, ...
'SliderStep',[1/NumFrames 2/NumFrames], ...
'Callback',@slider1_Callback);
This hides the formerly existing sliders and sets the slider value to 1 for each call.
Importing the list of files in all slider callbacks is a waste of time in addition.
Solution: Create the slider once only, either in GUIDE or in the OutputFcn (where it is done now already also). Then omit the re-creation by uicontrol.
I suggest to call the slider1_callback from the mouseScroll function.
  27 Comments
Stelios Fanourakis
Stelios Fanourakis on 17 Jun 2018
@Jan. You do helping me a lot with your suggestions. It seems I need to keep on forward myself from now and on. One slider I added on the GUIDE and one slider from uicontrol. When the figure is loading, it shows 2 sliders but only one of them actually works.
Now the bottom slider works but it works to infinity. I want the total range of the slider to be the number of image frames, e.g. 15
Stelios Fanourakis
Stelios Fanourakis on 17 Jun 2018
Debugger will only tell me the error point. It won't solve it.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!