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

2 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by