how to update string in a text uicontrol when clicking a checkbox
Afficher commentaires plus anciens
How should i realize that the string in the text uicontrol will automatically update when the checkbox is clicked.
function [] = gui_test()
% click a checkbox puts the string in a textbox.
S.fh = figure('units','pixels',...
'position',[300 300 600 400],...
'menubar','none',...
'name','test',...
'numbertitle','off',...
'resize','off');
S.cb = uicontrol('style','checkbox','string', 'water',...
'units','pix',...
'position',[200 300 100 30],'Callback',{@cb_Callback});
S.tx = uicontrol('style','text',...
'unit','pix',...
'position',[200 100 180 30]);
function cb_Callback
set(S.tx,'String',get(S.cb,'String'));
end
end
Thank you for your help.
2 commentaires
Walter Roberson
le 26 Sep 2013
When you use ... as the continuation marker, the next line cannot be empty or consist of comments only. If that next line does not finish the previous then there must be at least a continuation marker.
Réponses (2)
Walter Roberson
le 26 Sep 2013
0 votes
Add another 'end' statement at the end of what you have, so that there is an 'end' for cb_Callback and another end for gui_test() but which is after the 'end' for cb_Callback.
3 commentaires
Walter Roberson
le 26 Sep 2013
What result are you getting when you try?
Chong Tao
le 26 Sep 2013
Chong Tao
le 27 Sep 2013
0 votes
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!