how to choose the 1st popupmenu option without having to pick it

2 views (last 30 days)
Hi guys,
I have a popup menu with several options. I want the gui to assume the first option without having to choose it. like when i initialize the gui and i want to analyse the first option, i want to not have to pick it..
i tried defining the popupmenu variables in the opening function but the gui doesn´t recognize other variables defined within that popupmenu if i don´t pick the option..
i don´t know if i was clear enough but if somebody could help i would be much appreciated!
Inês

Answers (1)

Walter Roberson
Walter Roberson on 3 Jun 2015
You can have it positioned over the first option by setting the uicontrol Value parameter to 1.
If you also want it to take the action that would be done when the first entry is chosen, you have to call the callback yourself, such as
handles = guidata(gcf);
popup = handles.popup1; %use formal name of popup after "handles"
cb = get(popup, 'Callback');
set(popup, 'Value', 1); %choose first option
feval(cb, popup, []); %execute the popup passing the object and an empty event

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!