GUI of the button

Hi, I want to ask about button.
If the button want to be use once ,then the button couldn't be use,
anyway, button is used once,not twice or three times,
So, how to set the button for code.
Teach me, thank you!

 채택된 답변

Sean de Wolski
Sean de Wolski 2012년 8월 8일

0 개 추천

In its callback, disable it after it's pushed:
figure;
uicontrol('string','Push Me!','position',[10 10 100 50],'callback',@(src,evt)set(src,'enable','inactive','string','Now you can''t'));

댓글 수: 4

Pan
Pan 2012년 8월 8일
waht is "'callback',@(src,evt)"??
Pan
Pan 2012년 8월 8일
because this is my code"hplay1 = uicontrol('unit','pixel','style','pushbutton','string','play ',... 'position',[1250 110 85 50],'backgroundColor',[0.3,0.7,1],'fontsize',12,'units','normalized','callback',{@play1_callback});"
Sean de Wolski
Sean de Wolski 2012년 8월 8일
So play1_callback will automatically receive two inputs: src, the handle the button calling it and event which contains some event data or can be empty.
Above, I took the handle and set it's enable property to off and changed the string to show it happened. In your play1_callback, the first line should read:
set(src,'enable','inactive') %or 'off'
Alternatively, you could just make the button invisible if you wanted. 'visible','off'
Pan
Pan 2012년 8월 8일
Hellow , I want to ask you another question that
The button is pushed once, then if the button want to be pushed twice must wait few time(EX:2sec).
I don't how to do ,if you know please teach me thank you!!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

Pan
2012년 8월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by