How can I make an input dialog box created by INPUTDLG wide enough to show the entire title?

39 次查看(过去 30 天)
When I execute the following commands:
prompt = {'Rows:', 'Columns:'};
title_text = 'Please enter the desired matrix size';
a = inputdlg(prompt,title_text);
the dialog box is not wide enough to display the entire title.

采纳的回答

MathWorks Support Team
The ability to automatically set the width of the dialog box created by the INPUTDLG function in MATLAB is not available.
To work around this issue, do one of the following:
1. For the programmatic approach, instead of using the command:
a = inputdlg(prompt,title_text);
use the command:
a = inputdlg(prompt,title_text, [1, length(title_text)+N]);
where "N" is some positive integer. This will set width of input fields of the dialog box to length of the title plus a spacer "N", and increase the width of the dialog box accordingly. "N" should be chosen sufficiently large that the title is shown in its entirety. For example any value above 8 will result in the title being fully displayed.
2. To adjust the width manually, instead of using the command:
a = inputdlg(prompt,title_text);
use the command:
a = inputdlg(prompt,title_text, 1, {'' ''}, 'on');
This will set the "Resize" option of INPUTDLG to 'on', allowing the user to manually resize the dialog box to the appropiate width such that the title is fully displayed.
  1 个评论
Image Analyst
Image Analyst 2014-8-29
编辑:Image Analyst 2014-8-29
No, your code is not a solution. You didn't put in code to demonstrate the problem of a really long title not displaying since your title was so short, only the 4 characters 'Save'. Try this to demonstrate:
prompt = {'Enter filename:'};
dlg_title = 'This is a really long title that will not display';
num_lines = 1;
def = {'default answer'};
outputfile = inputdlg(prompt,dlg_title,num_lines,def);
The title just says "This is a...". This will work though:
N = 22;
prompt = {'Enter filename:'};
title_text = 'This is a really super long title that will display';
num_lines = 1;
def = {'default answer'};
caUserResponse = inputdlg(prompt,title_text, [1, length(title_text)+N]);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

标签

产品


版本

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by