input dialog box options

조회 수: 36 (최근 30일)
Razvan
Razvan 2012년 11월 8일
Hi,
I tried one of the examples from the inputdlg documentation http://www.mathworks.com/help/matlab/ref/inputdlg.html but it seems it is not working...
I am interested to make the dialog resize such that the text appears completely. The example from the documentations is like this:
prompt={'Enter the matrix size for x^2:',...
'Enter the colormap name:'};
name='Input for Peaks function';
numlines=1;
defaultanswer={'20','hsv'};
options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';
answer=inputdlg(prompt,name,numlines,defaultanswer,options);
My questions/problems are the following:
  1. Why the dialog is not rescaled, and the title is "Input fo..." instead of "Input for Peaks function"?
  2. What are the WindowStyle options supposed to do? The options are 'normal' or 'modal' but the documentation doesn't say what is the difference between these 2, and I also didn't notice any difference.
  3. How can I make the Enter key to press the active button of the dialog, i.e. instead of moving the mouse and click the button I want to just press Enter after I entered the values in the dialog. Is this possible?
Thanks,
Razvan

채택된 답변

Walter Roberson
Walter Roberson 2012년 11월 8일
편집: Walter Roberson 2012년 11월 8일
1) resize refers to whether the user can resize the window.
2) modal means that the user is not allowed to interact with any other figure GUI; normal means that the user is allowed to interact with other figure GUIs.
3) copy the code for inputdlg.m and edit it to do what you want. I would not advise doing what you propose, though, as it is common for users to press return in edit boxes to indicate that they have completed that one field, and you do not want the dialog to be considered to be completed if the user presses return in the first edit box before having proceeded to the next.
Have you considered tabbing to the OK box and then pressing return? That behavior is already built-in.
  댓글 수: 3
Razvan
Razvan 2012년 11월 8일
One more question: if I modify the inputdlg.m file, can I move the new file in the current directory or I have to let it in the folder with the old file (C:\Program Files\MATLAB\R2012b\toolbox\matlab\uitools\inputdlg.m in my case)?
Walter Roberson
Walter Roberson 2012년 11월 8일
inputdlg() is, if I recall correctly, safe to copy to your path. Some of the other ui routines are in class directories and will not work properly outside of those directories (or copies of them)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Razvan
Razvan 2012년 11월 8일
I found another option to modify the width of the dialog. One can use a matrix for the "numlines" parameter (as described in the documentation).
For example this code will create a wider dialog:
prompt={'Enter the matrix size for x^2:',...
'Enter the colormap name:'};
name='Input for Peaks function';
numlines=[1 50; 1 50];
defaultanswer={'20','hsv'};
answer=inputdlg(prompt,name,numlines,defaultanswer);
which is what I wanted initially.

카테고리

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