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

17 ビュー (過去 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
MathWorks Support Team 2013 年 3 月 6 日
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 Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by