Combining Edit Text & Popup Menu Code in a Popup Menu Callback?

Hi, just wondering if there's any way I can combine "edit text" and "popup menu" codes into a push button? Capture.JPGIs there any way the codes (from the "Edit Text" and "Popup Menu" run together when I run the push button?
Thanks in advance!

2 comentarios

Regina - please clarify what you mean by if there's any way I can combine "edit text" and "popup menu" codes into a push button. When the user presses the push button, what do you want to happen? Do you want to read the text from the edit text control and read the pop-up menu choice? Or do you mean something else?
In my GUI, I have both Text Editor & Pop-up menu. When the user clicks the push button, I expect it to read the edit text AND the popup menu choice.
for example,
in the popup menu, there’s a list of different cube dimentions, while in the edit text, a user can input the number/ amount of cubes. When the push button is executed, it should calculate & display the total volume of cubes that he/she has..
Is this possible? If so, how?
(I hope you get the picture..)
thanks!

Iniciar sesión para comentar.

 Respuesta aceptada

Regina - in the callback for the push button, use the handles structure to get access to the edit texet control and the pop-up menu. Use the get function to get the text or selection (from the menu). For example, the callback for your button might be
function pushbutton1_Callback(hObject, eventdata, handles)
% get the text value from the edit text control
numberOfCubes = str2double(get(handles.edit1, 'String'));
% get the number of dimensions
popupMenuItems = get(handles.popup1, 'String'); % assume cell array of strings for list of dims
numberOfDimensions = str2double(popupMenuItems{get(handles.popup1,'Value')});
end

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 20 de Nov. de 2018

Respondida:

el 26 de Nov. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by