mlapptools
is an example set of static MATLAB methods for manipulating the DOM underlying the App Designer UI elements formally introduced in R2016a
For additional information, see Iliya Romm's guest Undocumented Matlab article, Customizing uifigures part 2, published Wednesday, September 7th, 2016
textAlign
- Modify text alignment
fontWeight
- Modify font weight
fontColor
- Modify font folor
setStyle
- Modify a specified style property
Set the horizontal text alignment of the specified UI element, uielement
, to that specified by the input alignment string, alignment
.
Valid alignment strings are:
'left'
- Left align (default)'center'
- Center align'right'
- Right align'justify'
- Each line has equal width'initial'
- Revert to default
Using the demo GUI generated by ./Demo/DOMdemoGUI.m
myGUI = DOMdemoGUI;
mlapptools.textAlign(myGUI.TextArea, 'center');
myGUI = DOMdemoGUI;
mlapptools.textAlign(myGUI.TextArea, 'right');
Set the font weight of the specified UI element, uielement
, to the input weight string or integer, weight
.
Valid font weight property values are:
'normal'
- Normal characters (default)'bold'
- Thick characters'bolder'
- Thicker characters[400, 600, 800]
- Integers mapping to'normal'
,'bold'
, and'bolder'
. Intermediate integers (and floats) are accepted but generally map to these 3 values'initial'
- Revert to default
Using the demo GUI generated by ./Demo/DOMdemoGUI.m
myGUI = DOMdemoGUI;
mlapptools.fontWeight(myGUI.TextArea, 'bold');
myGUI = DOMdemoGUI;
mlapptools.fontWeight(myGUI.TextArea, 600);
Set the font color of the specified UI element, 'uielement'
, to the input color, newcolor
. newcolor
can be a predefined color string or a string containing a valid CSS color method call.
Valid color specifications are:
- Hexadecimal colors - e.g.
'#ff0000'
for red - RGB colors - e.g.
'rgb(255,165,0)'
for orange - RGBA colors - e.g.
'rgba(255,255,0,0.3)'
for yellow - HSL colors - e.g.
'hsl(120, 100%, 50%)'
for green - HSLA colors - e.g.
'hsla(240,100%,50%, 1.0)'
for blue - Predefined color names - e.g.
'red'
,'orange'
,'yellow'
,'green'
,'blue'
,'indigo'
,'violet'
. For more colors, see the predefined color names CSS color specification.
Using the demo GUI generated by ./Demo/DOMdemoGUI.m
myGUI = DOMdemoGUI;
mlapptools.fontColor(myGUI.TextArea, 'aqua');
myGUI = DOMdemoGUI;
mlapptools.fontColor(myGUI.TextArea, 'rgb(255,165,0)');
Set the style attribute styleAttr
of the specified UI element, 'uielement'
, to the value styleValue
. styleAttr
should be any valid CSS attribute, and styleValue
a valid setting thereof.
This method provides a general interface to change CSS style attributes, with minimal input testing and error reporting, so it is up to the user to provide valid inputs.
Valid style attributes and corresponding settings can be found here.
Using the demo GUI generated by ./Demo/DOMdemoGUI.m
myGUI = DOMdemoGUI;
mlapptools.setStyle(myGUI.TextArea, 'background-image',...
'url(https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg)');