MATLAB: Slider is not working in the GUI

guiguideimage processingmousescrollslider

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?

Best Answer

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.
Related Question