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 件のコメント

Geoff Hayes
Geoff Hayes 2018 年 11 月 20 日
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?
Regina Yacika
Regina Yacika 2018 年 11 月 25 日
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!

サインインしてコメントする。

 採用された回答

Geoff Hayes
Geoff Hayes 2018 年 11 月 26 日

1 投票

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

質問済み:

2018 年 11 月 20 日

回答済み:

2018 年 11 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by