How do i detect button pressed in uicontrol?

3 visualizzazioni (ultimi 30 giorni)
Elsie
Elsie il 23 Giu 2014
Commentato: Elsie il 24 Giu 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

Risposte (1)

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

Accedi per commentare.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by