- <matlabroot>\toolbox\matlab\uitools\private\getnicedialoglocation.m
- <matlabroot>\toolbox\matlab\uitools\private\setdefaultbutton.m
How to get larger font size for inputdlg, MATLAB ver 2019a
53 views (last 30 days)
Show older comments
I am using MATLAB 2019a (the latest MATLAB version my network administration allows) and I have been unable to change the font size for the input boxes for inputdlg. How can I do this?
Some things I have tried:
opts.Interpreter = 'tex';
opts.Resize = 'on';
dlgtitle = 'Simulation Inputs';
prompt = {'\fontsize{12} Input #0:', ...
'Input #1:','Input #2','Input #3', ...
'\fontsize{12} Input #4:', ...
'Input #5:','Input #6:'};
fieldsize = [2 45; 1 45; 1 45; 1 45; 1 45; 1 45; 1 45];
definput = {'\fontsize{12} 0.3', ...
'60','29','60', ...
'\fontsize{12} 0', ...
'377','-385'}; % default values
%answer = inputdlg(prompt,dlgtitle,fieldsize,definput);
answer = inputdlg(prompt,dlgtitle,fieldsize,definput,opts);
This code produces the input dialog box with the 'prompt' values with the font size specified. However, the definput values are not. I just get the text '\fontsize{12} Input #0:' and '\fontsize{12} 0.3' without any change in the font size.
I got the '\fontsize' code from:
https://www.mathworks.com/help/matlab/ref/inputdlg.html
BTW, I found the instructions for the dialog box settings to be cryptic and they have nowhere near enough examples to show what they mean, especially since the syntax has to be perfect for the commands to work.
I also notice that the command:
set(0, 'DefaultUICOntrolFontSize', 12);
works just fine for listdlg for making the fonts larger, but has no effect on inputdlg. That is just irritating.
I did look at this answer that implies that the fontsize in the input boxes can be changed, but the answer was unhelpful and more about the box size:
0 Comments
Answers (1)
Voss
on 11 Mar 2024
Edited: Voss
on 11 Mar 2024
The Accepted Answer in the thread you linked to actually contains all the information you need.
The only thing I would clarify is in reference to what Walter said in his comment: "You might need to copy some other functions as well." I needed to copy two functions (in addition to copying and renaming inputdlg.m itself) in order to get it to work (in R2022a):
After copying those files, renaming inputdlg.m to inputdlg_modified.m, and changing the line in inputdlg_modified.m that uses FactoryUicontrolFontSize to use DefaultUicontrolFontSize instead, as described in the linked thread, I ran the following code:
opts.Resize = 'on';
dlgtitle = 'Simulation Inputs';
prompt = {'Input #0:', ...
'Input #1:','Input #2','Input #3', ...
'Input #4:', ...
'Input #5:','Input #6:'};
fieldsize = [2 45; 1 45; 1 45; 1 45; 1 45; 1 45; 1 45];
definput = {'0.3', ...
'60','29','60', ...
'0', ...
'377','-385'}; % default values
fs_uic = get(groot(),'DefaultUIControlFontSize');
set(groot(),'DefaultUIControlFontSize',16);
answer = inputdlg_modified(prompt,dlgtitle,fieldsize,definput,opts);
set(groot(),'DefaultUIControlFontSize',fs_uic);
and got the following input dialog window:
7 Comments
Walter Roberson
on 11 Mar 2024
Edited: Walter Roberson
on 11 Mar 2024
The following has been checked against R2019a, and should work for Windows, MacOS, or Linux
if ~exist('private', 'dir'); mkdir('private'); end
PR = fullfile(matlabroot, 'toolbox/matlab/uitools/private');
copyfile( fullfile(PR, 'getnicedialoglocation.m', 'private/'));
copyfile( fullfile(PR, 'setdefaultbutton.m'), 'private/');
See Also
Categories
Find more on Environment and Settings 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!