I'm not convinced that the addlistener is not working. Please explain your opinion about "implicit calling of functions", because this is actually teh best and most direct solution. Any callback method will be a kind of implicit calling, so there is no other way.
If a slider is really not working for you, you can simulate a slider by drawing some graphic objects manually and track mouse clicking and moving using the WindowButtonDown and WindowBuittonMotion function. But hand made GUI elements are a mess and using already existing methods is much smarter.
I assume the solution is to get rid of the problems you have with "implicit calling of functions" and use the standard listener method as explained at Answers: continuous-slider-callback . [EDITED] This thread already contains all hints, which are needed. You are still posting the same piece of code. So let me try to summarize the steps to solve the problem:
- Add the listener in the OpeningFcn:
addlistener(handles.Slider1 ,'Value', 'PostSet', @ContSliderDragCB);
- Now the callbacks for the slider and the listener:
function slider1_Callback(hObject, eventdata, handles)
Value = get(hObject, 'Value');
set(handles.edit1,'String', num2str(Value));
function ContSliderDragCB(hObject, eventdata)
handles = guidata(hObject);
Value = get(eventdata.AffectedObject, 'Value');
set(handles.edit1,'String', num2str(Value));
- Avoid globals, because they are a shot in your knee. There is not need for a global, because the value of the slider is stored in the slider already.