필터 지우기
필터 지우기

how to update string in a text uicontrol when clicking a checkbox

조회 수: 3 (최근 30일)
Chong Tao
Chong Tao 2013년 9월 26일
답변: Chong Tao 2013년 9월 27일
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
Walter Roberson
Walter Roberson 2013년 9월 26일
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.
Chong Tao
Chong Tao 2013년 9월 27일
편집: Chong Tao 2013년 9월 27일
I added the empty lines to show them as code on this web. The real code doesn't have this problem.

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2013년 9월 26일
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
Walter Roberson
Walter Roberson 2013년 9월 26일
What result are you getting when you try?
Chong Tao
Chong Tao 2013년 9월 26일
no response in the text box.

댓글을 달려면 로그인하십시오.


Chong Tao
Chong Tao 2013년 9월 27일
can anyone please help with this question? Thanks

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by