A short question regarding the pushbutton in GUI

I am new to the GUI design. Any help will be highly appreciated!!
I am trying to use a pushbutton/toggle button in my GUI. Basically I want it to be like intially display 'off', and when I click it, it will display 'on', and click it again, then 'off' again.
Thank you!!

댓글 수: 1

Jan
Jan 2012년 2월 25일
What exactly is your question? Are you using GUIDE? What have you tried already an which problems occurred?

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

 채택된 답변

Jan
Jan 2012년 2월 25일

1 개 추천

A small example:
uicontrol('Style', 'togglebutton', 'String', 'off', ...
'Value', 0, ...
'Callback', @myToggleCallback);
function myToggleCallback(ButtonH, EventData)
if strcmp(get(ButtonH, 'String'), 'off')
set(ButtonH, 'String', 'on');
else
set(ButtonH, 'String', 'off');
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

질문:

2012년 2월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by