How to call popup menu data in push button?
1 view (last 30 days)
Show older comments
Hello, With the help of popup menu I am getting data from the user as follows:
selection = get(hObject, 'Value');
switch selection
case 1
h=msgbox('Please select the Surface');
case 2
surface2=0;
case 3
surface2=1;
prompt = {'Enter the radius (mm)','Enter the x ','Enter the y '};
dlg_title = 'Sphere';
num_lines = 1;
defaultans = {'','0','0'};
answer = inputdlg(prompt,dlg_title,num_lines,defaultans);
r_sphere=str2num(answer{1});
x0=str2num(answer{2});
y0=str2num(answer{3});
From above I get some specific inputs from users. Now I need to use them in later part of the code. I have a push button where I calculate things and there remains my remaining code. Now what is my problem is I am not able to call back the popup menu inputs to run the code in pushbutton. Can anyone suggest a way to get values of popup into push button?
1 Comment
Answers (1)
Geoff Hayes
on 2 Jun 2016
adi - I am assuming that you are using GUIDE to create your GUI (given the hObject reference in the above code). If that is the case, then you can use the handles structure to reference the popupmenu control from within the pushbutton callback. For example,
function pushbutton1_Callback(hObject, eventdata, handles)
selectedItemIndex = get(handles.popupmenu1,'Value');
% etc.
The above will allow you to access the index of the selected item of the popup menu from within the pushbutton callback.
0 Comments
See Also
Categories
Find more on Specifying Target for Graphics Output 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!