Filter löschen
Filter löschen

How do i detect button pressed in uicontrol?

5 Ansichten (letzte 30 Tage)
Elsie
Elsie am 23 Jun. 2014
Kommentiert: Elsie am 24 Jun. 2014
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

Antworten (1)

Image Analyst
Image Analyst am 23 Jun. 2014
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 Kommentar
Elsie
Elsie am 24 Jun. 2014
nice link! i am still learning. Thanks. i also think that writing all controls at a time is very difficult for further maintenance.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by