does someone know if it's possible to have popupmenu in inputdlg?

2 ビュー (過去 30 日間)
Aleksandar Petrov
Aleksandar Petrov 2017 年 9 月 8 日
回答済み: Image Analyst 2017 年 9 月 8 日
Hello,
I am familiar with the use of inputdlg but unfortunately the input fields accept only text and numbers! does someone know if it's possible to have popupmunu or listbox so I can select among a list of possible inputs?
Thank you, Aleksandar
  2 件のコメント
Adam
Adam 2017 年 9 月 8 日
The generalised dialogs that come with Matlab tend to be fixed in what they contain. For more specialised behaviour you generally have to program your own.
Aleksandar Petrov
Aleksandar Petrov 2017 年 9 月 8 日
yes, I can program a dialog box but the problem is that in my entire GUI I use inputdlg to input parameters so the style of all input dialog is the same. when I program my own dialog it differs a lot from the others. not only the position where they appear but also the font style, the distance between lines and so on. maybe if I know the default parameter of the inputdlg I could program by myself exactly the same style dialog. Thank you, Aleksandar

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

採用された回答

Joseph Cheng
Joseph Cheng 2017 年 9 月 8 日
編集済み: Joseph Cheng 2017 年 9 月 8 日
Absolutely you can, however its not as straight forward as inputdlg() or questdlg(). you'll want to look at the example here:
which is pretty much the same example i was about code out for you.
  3 件のコメント
Joseph Cheng
Joseph Cheng 2017 年 9 月 8 日
Then you should state these details.
if you know how to code your own popupmenu you can then use the parameters based of of the inputdlg() function.
you can edit or find the default parameters that are used in inputdlg() by looking at its source code.
edit inputdlg
you can then edit inputdlg to create a popupdlg function. some items that you'll need to create copy fro private uicontrol folders (items i copied over is "setdefaultbutton" and "getnicedialoglocation".) change the uicontrol section which creates the edit, change it to a popup style,
EdInfo=StInfo;
EdInfo.FontWeight = get(InputFig,'DefaultUicontrolFontWeight');
EdInfo.Style = 'edit';
EdInfo.BackgroundColor = 'white';
change that line EdInfo.Style to type popup
EditHandle(lp)=uicontrol(InputFig , ...
EdInfo , ...
'Max' ,NumLines(lp,1) , ...
'Position' ,[ TxtXOffset EditYOffset(lp) TxtWidth EditHeight(lp)], ...
'String' ,DefAns{1p} , ...
'Tag' ,'Edit' ...
);
≈ line 248: then you can then change the string to just the DefAns to show all entries. up to you to change the tag which you'll have to go find the tag callouts in around line 416 for the multicolumn. After that you'll then have to find the okay pushbutton callback to only return the selected answer not the default cell matrix.
Joseph Cheng
Joseph Cheng 2017 年 9 月 8 日
if you cannot find the private functions, put a breakpoint in inputdlg, then use the "which" function
which setdefaultbutton
which getnice....
button to find the files to paste into the bottom of the popupdlg function you'll be creating.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2017 年 9 月 8 日
Perhaps you'd be interested in listdlg() which gives a listbox. Or menu() which gives a bunch of buttons.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by