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

2 views (last 30 days)
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 Comments
Adam
Adam on 8 Sep 2017
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 on 8 Sep 2017
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

Sign in to comment.

Accepted Answer

Joseph Cheng
Joseph Cheng on 8 Sep 2017
Edited: Joseph Cheng on 8 Sep 2017
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 Comments
Joseph Cheng
Joseph Cheng on 8 Sep 2017
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 on 8 Sep 2017
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.

Sign in to comment.

More Answers (1)

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

Categories

Find more on Migrate GUIDE Apps 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!