does someone know if it's possible to have popupmenu in inputdlg?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Aleksandar Petrov
le 8 Sep 2017
Réponse apportée : Image Analyst
le 8 Sep 2017
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 commentaires
Adam
le 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.
Réponse acceptée
Joseph Cheng
le 8 Sep 2017
Modifié(e) : Joseph Cheng
le 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 commentaires
Joseph Cheng
le 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
le 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.
Plus de réponses (1)
Image Analyst
le 8 Sep 2017
Perhaps you'd be interested in listdlg() which gives a listbox. Or menu() which gives a bunch of buttons.
0 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!