How can I make an input dialog box created by INPUTDLG wide enough to show the entire title?
41 views (last 30 days)
Show older comments
MathWorks Support Team
on 6 Mar 2013
Edited: Image Analyst
on 29 Aug 2014
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.
Accepted Answer
MathWorks Support Team
on 6 Mar 2013
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 Comment
Image Analyst
on 29 Aug 2014
Edited: Image Analyst
on 29 Aug 2014
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]);
More Answers (0)
See Also
Categories
Find more on String in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!