フィルターのクリア

How do i detect button pressed in uicontrol?

5 ビュー (過去 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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by