Matlab: Get value from popup menu before choosing an item
<p>I’m working on a GUI with a couple of popup menus. The problem is, if you run the program and you don’t choose anything from the menu, the value is set on what it was the last time I ran the program. I got this in my opening function (tag_port and tag_speedunit are the tags for two of the popup menus):</p>

<pre><code> set(handles.tag_port,'Value',1);
set(handles.tag_speedunit,'Value',1);
</code></pre>

<p>But that doesn’t work. By changing the value it only changes which item is shown in the popup menu when running the program, but if you don’t pick anything it is still stuck on what you picked last time you ran it.</p>

<p>my popup funktion looks like that:</p>

<pre><code>function tag_port_Callback(hObject, eventdata, handles)
% That'll give me all the Choices in the popup menu
contents = get(hObject,'String');
% That'll give the value of the specific choice
popChoice = contents{get(hObject,'Value')};
setappdata(0,'popChoice',popChoice);

%end of every funktion
guidata(hObject,handles);
</code></pre>

<p>and in my main function I'm asking for the value:</p>

<pre><code>popChoice = getappdata(0,'popChoice')
</code></pre>

<p>But as I said popChoice won't give me the popup value '1' unless i choose it by clicking on it.</p>

<p>Any ideas??? Thanks so much in advance.</p>