How do I update my slider using an edit text?
Mostrar comentarios más antiguos
So my edit text is able to change the value of my slider, but only after the slider is clicked on, is there any way that the slider could be updated continuously or after I hit enter? Here is my code in the slider callback:
val=str2num (get (handles.edit1, 'String'));
set(handles.slider1, 'Value', val);
1 comentario
I would suggest that you create a generic callback function, and give each of your objects a Tag with an appropriate name.
In this case, the edit box would have
set(handles.edit1,'Tag','handles.edit')
and slider would be
set(handles.slider1,'Tag','handles.slider1')
Assign a generic callback to each
set(handles.edit1,'Callback',@genericCB)
set(handles.slider1,'Callback',@genericCB)
Now you create the generic callback that reads the Tag
function genericCB(src,eventdata)
handleLink = get(src,'Tag')
if any(regexp(handleLink,'edit1'))
% The edit1 object was called, update slider1
elseif any(regexp(handleLink,'slider1'))
% The slider1 object was called, update edit1
end
Edit: When you enter a value into the edit box, the callback will not be called until you click outside of the edit box or press on the keyboard. If you want the slider to update as you are typing, I believe you'll need to create a java object instead of a uicontrol object
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Desktop en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!