MATLAB Answers

uitextarea not displaying correct font

2 views (last 30 days)
James Johnson
James Johnson on 20 Oct 2020
Edited: Mario Malic on 26 Oct 2020
I'm editing code that was exported from the app designer to create a GUI. I want the user to edit code directly in a textbox of the GUI. The textbox is child of a tab in a tab group, which is a child of the uifigure.
The GUI will not display fonts in the TextArea object with any font other than MATLAB's default. All attempts to render with a different font fail.
Here are my attempts
Attempt 1
desiredFont='Monospaced';
app.SpecifyconfigurationinformationTextArea = uitextarea(app.ConfigurationInformationTab,'FontName',desiredFont);
app.SpecifyconfigurationinformationTextArea.Position = [102 17 329 412];
app.SpecifyconfigurationinformationTextArea.Value = loadOldConfigCommand(app);% just returns a cell array of strings;
Attempt 2
desiredFont='Monospaced';
app.SpecifyconfigurationinformationTextArea = uitextarea(app.ConfigurationInformationTab);
app.SpecifyconfigurationinformationTextArea.FontName = desiredFont;
app.SpecifyconfigurationinformationTextArea.Position = [102 17 329 412];
app.SpecifyconfigurationinformationTextArea.Value = loadOldConfigCommand(app);% just returns a cell array of strings;
I have also tried other fonts
desiredFont='FixedWidth'; % fails
desiredFont='Times New Roman'; % fails
desiredFont='Comic Sans'; % nope
desiredFont='Courier New'; % fails
No matter what I do, when the app renders it renders like this (closing all windows and clearing all variables between attempts)

  0 Comments

Sign in to comment.

Answers (1)

Mario Malic
Mario Malic on 21 Oct 2020
Edited: Mario Malic on 22 Oct 2020
FontName is not a valid Name-Value pair argument. You can change font after you create text box.
app.SpecifyconfigurationinformationTextArea.FontName = 'Monospaced';

  4 Comments

Show 1 older comment
Mario Malic
Mario Malic on 24 Oct 2020
I tested out the attempt 2 and it works for me. I ran a demo app from command window, and ran the command through command window. Can you check interactivity panel on the your Text Editor, if Editable property is enabled?
James Johnson
James Johnson on 26 Oct 2020
Editable property is enabled. It does not work on R2020a, but does work on R2020b. So I just upgraded.
Mario Malic
Mario Malic on 26 Oct 2020
Alright, I guess that might have been a bug that has been fixed meanwhile. I am on 2020b as well.

Sign in to comment.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!