Function control with reference to GUI
Show older comments
Hé Matlabbers,
I was struggling in Matlab and still can't solve this problem.
I have a M-File where I create this to uicontrols in a GUI.
edXi = uicontrol(ph,'Style','edit',...
'String','0',...
'Position',[200 52 100 20]);
edYi = uicontrol(ph,'Style','edit',...
'String','0',...
'Position',[150 52 100 20]);
pbLock = uicontrol(ph,'Style','togglebutton','String','Lock',...
'Units','normalized','Callback',@lock_call,...
'Position',[.1 .80 .4 .15]);
When someone press the togglebutton, the function below (written in a different m file) has to be executed. Only how do I give the reference of the 'edit' uicontrol to the function to change the string in the 'Edits' within the function?
function lock_call(hObject,eventdata)
set(edXi,'String',num2str(pos(1)));
set(edYi,'String',num2str(pos(2)));
end
Answers (1)
Michael ten Den
on 20 May 2012
Categories
Find more on Startup and Shutdown 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!