Is it possible to use an interpreter in UIdropdown items names?

Hi,
I am designing an app with the App Designer. I want to add a drop down menu to choose the size of a capacitor. The menu items have to correspond to the order of magnitude of the capacity, i.e. F, mF, μF, nF. Is there a way to have the "μ" written as a symbol? I can't find an option to use the latex or tex interpreter to have the symbol appear as desired. Thanks in advance for any help.

3 Comments

For characters with a corresponding Alt keyboard sequence you can type the Alt code. For µF just type ALT+230 and F.
If you are running on Windows, you can also use the Character Map to select and copy characters from there. This works well as long as all the characters you need are from the same set - the characters will show correctly as long as you pick the matching font name in the FontName dropdown menu.
@Ampt Ampt I suggest copying your comment to the Answers section.
@Ampt Ampt thanks a lot, will try this solution ASAP in my project!

Sign in to comment.

 Accepted Answer

Starting in R2023a you can use addStyle to specify an interpreter for a drop-down component or specific drop-down items. You can use an interpreter value of 'tex' or 'latex'.
fig = uifigure;
dd = uidropdown(fig, ...
Items=["F","mF","\muF","nF"], ...
Value = "\muF");
s = uistyle(Interpreter="tex");
addStyle(dd,s)

5 Comments

@Jasmine Poppick Is there a work around for 2022b? Is it not possible to do something in startup function and access the dd properties? to change its interpreter and alignment.
@Mohammed Azharuddin The ability to add a style to drop-down UI components was first introduced in R2023a. However, in previous releases you can paste unicode characters such as μ directly into the text of the Items property and the characters will appear in the drop-down list.
@Jasmine Poppick Thanks for clarifying it. I wanted the latex interpreted font style for the dropdown label, so every text looks in the same fashion. Also, is there a way to also align the items in the dropdown? or are these two options available only in 2023a onwards? since, I saw we could use the dropdownhandle to control the colors of items, cruiosu with these doubts. Thanks
@Jasmine Poppick Found a way to use interpreter latex for the label of dropdown field, double clicking / selecting the label text displays an option for interpreter. However, is there an option for the items styling or does it exists only in 2023a?
One followup question another topic, Is there a way the checkbox field text can be interpreted in latex? Thank you.
@Mohammed Azharuddin For label UI components, the ability to interpret text as LaTeX or HTML using the Interpreter property was added in R2021a. Styling of individual drop-down items using addStyle, including specifying an interpreter, color, or alignment, is only available starting in R2023a.
For check boxes, currently you cannot specify an interpreter for the check box text. However, as a workaround, you can delete the text from the check box Text property, and instead create a separate label UI component next to the check box. You can then specify an interpreter for the Label object.

Sign in to comment.

More Answers (1)

For characters with a corresponding Alt keyboard sequence you can type the Alt code. For µF just type ALT+230 and F.
If you are running on Windows, you can also use the Character Map to select and copy characters from there. This works well as long as all the characters you need are from the same set - the characters will show correctly as long as you pick the matching font name in the FontName dropdown menu.

Categories

Find more on Develop Apps Programmatically 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!