필터 지우기
필터 지우기

How do i detect button pressed in uicontrol?

조회 수: 2 (최근 30일)
Elsie
Elsie 2014년 6월 23일
댓글: Elsie 2014년 6월 24일
I have two buttons in my figure window, and i want to perform different operation for this two button, but i don't know how to detect which button is pressed? Thanks a lot.
f = figure;
u1 = uicontrol('Style','push', 'parent', f,'pos',...
[750 50 60 60],'string','Back','Enable','off','Callback','uiresume(gcbf)');
u2 = uicontrol('Style','push', 'parent', f,'pos',...
[830 50 60 60],'string','Next','Enable','off','Callback','uiresume(gcbf)');
align([u1,u2],'distribute','bottom');
if buttonBack is pressed...?
.....
end
if buttonNext is pressed..?
....
end

답변 (1개)

Image Analyst
Image Analyst 2014년 6월 23일
You need to define separate callback functions, rather than 'uiresume(gcbf)' like you did.
I suggest you look at this GUIDE tutorial which will make it a lot easier than trying to manually create dozens of controls one at a time for your GUI, which can be rather tedious since, as you can see, there are a lot of input arguments you have to worry about. http://blogs.mathworks.com/videos/category/gui-or-guide/
  댓글 수: 1
Elsie
Elsie 2014년 6월 24일
nice link! i am still learning. Thanks. i also think that writing all controls at a time is very difficult for further maintenance.

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

카테고리

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