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

조회 수: 6 (최근 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
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 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