Popup selection dictated by button selection

1 view (last 30 days)
I have 2 push buttons on my GUI.
When I push pushbutton 1, I want popup menu 1 to show, similarly when I push pushbutton 2 I want popup menu 2 to show. During start up I don't want any popup menus to show, only the pushbuttons.
In other words I would like the pushbutton selection to determine the popup menus.

Accepted Answer

Image Analyst
Image Analyst on 11 Mar 2016
Set the Visible property to both popups to false/off. Then in the callback for button 1, set the visibilities
handles.popup1.Visible = 'on'; % or 1 - not sure.
handles.popup2.Visible = 'off'; % or 0 - not sure.
In the callback for button 2, set the visibilities
handles.popup1.Visible = 'off'; % or 0 - not sure.
handles.popup2.Visible = 'on'; % or 1 - not sure.
If you have an old version and the OOP way of setting properties doesn't work, then use set():
set(handles.popup1, 'Visible', 'off');
  2 Comments
Jay
Jay on 12 Mar 2016
Edited: Jay on 12 Mar 2016
I just realised that in order to turn the visibility off I needed to change them in GUIDE and not in the function by coding.
MatLab 2013 requires the older code and wont allow OOP.
Thankyou for your help.
Image Analyst
Image Analyst on 12 Mar 2016
Actually, you can turn the visibility on or off either in GUIDE or in the m-file. They both will work.
If you want it to come up with a certain visibility, you can either do it in GUIDE (which is what I do), or you can do it in the OpeningFcn() function with the set() function like I showed.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!