11![ Minimum Version] ( https://img.shields.io/badge/Requires-R2016a%20%28v9.0%29%20or%20newer-orange.svg )
22
33# mlapptools
4- ` mlapptools ` is a collection of static methods for customizing the R2016a-introduced web-based ` uifigure ` windows and
5- associated UI elements through DOM manipulations.
64
7- For additional information, see Iliya Romm's Undocumented Matlab guest article,
8- [ * Customizing uifigures part 2* ] ( http://undocumentedmatlab.com/blog/customizing-uifigures-part-2 ) ,
5+ ` mlapptools ` is a collection of static methods for customizing the R2016a-introduced web-based ` uifigure ` windows and
6+ associated UI elements through DOM manipulations.
7+
8+ For additional information, see Iliya Romm's Undocumented Matlab guest article,
9+ [ * Customizing uifigures part 2* ] ( http://undocumentedmatlab.com/blog/customizing-uifigures-part-2 ) ,
910published Wednesday, September 7th, 2016.
1011
1112#### Contact us
12- - Feature requests/suggestions and bug repots - please feel free to
13+
14+ - Feature requests/suggestions and bug repots - please feel free to
1315[ open an issue] ( https://github.com/StackOverflowMATLABchat/mlapptools/issues ) in the repository.
1416- General discussion - [ _ MATLAB and Octave_ chatroom on Stack Overflow] ( https://chat.stackoverflow.com/rooms/81987/ ) .
15- - Specific questions about manipulating uifigures / App Designer apps -
17+ - Specific questions about manipulating uifigures / App Designer apps -
1618[ ` matlab-app-designer ` tag on Stack Overflow] ( https://stackoverflow.com/questions/tagged/matlab-app-designer ) .
17-
19+
1820## Methods
19- [ ` aboutDojo ` ] ( #aboutDojo ) - Return the dojo toolkit version.
20- [ ` fontColor ` ] ( #fontColor ) - Modify font color.
21- [ ` fontWeight ` ] ( #fontWeight ) - Modify font weight.
22- [ ` getHTML ` ] ( #getHTML ) - Return the full HTML code of a ` uifigure ` .
23- [ ` getWebElements ` ] ( #getWebElements ) - Extract a ` webwindow ` handle and a widget ID from a ` uifigure ` control handle.
24- [ ` getWebWindow ` ] ( #getWebWindow ) - Extract a ` webwindow ` handle from a ` uifigure ` handle.
25- [ ` getWidgetInfo ` ] ( #getWidgetInfo ) - Gather information about a specific dijit widget.
26- [ ` getWidgetList ` ] ( #getWidgetList ) - Gather information about all dijit widget in a specified ` uifigure ` .
27- [ ` setStyle ` ] ( #setStyle ) - Modify a specified style property.
28- [ ` setTimeout ` ] ( #setTimeout ) - Override the default timeout for dojo commands, for a specific ` uifigure ` .
29- [ ` textAlign ` ] ( #textAlign ) - Modify text alignment.
30-
31- <a name =" aboutDojo " ></a >
32- #### * mlapptools* .** aboutDojo** ()
21+
22+ [ ` aboutJSLibs ` ] ( #aboutJSLibs ) - Return the loaded versions of Dojo and React.
23+ [ ` fontColor ` ] ( #fontColor ) - Modify font color.
24+ [ ` fontWeight ` ] ( #fontWeight ) - Modify font weight.
25+ [ ` getHTML ` ] ( #getHTML ) - Return the full HTML code of a ` uifigure ` .
26+ [ ` getWebElements ` ] ( #getWebElements ) - Extract a ` webwindow ` handle and a widget ID from a ` uifigure ` control handle.
27+ [ ` getWebWindow ` ] ( #getWebWindow ) - Extract a ` webwindow ` handle from a ` uifigure ` handle.
28+ [ ` getWidgetInfo ` ] ( #getWidgetInfo ) - Gather information about a specific dijit widget.
29+ [ ` getWidgetList ` ] ( #getWidgetList ) - Gather information about all dijit widget in a specified ` uifigure ` .
30+ [ ` setStyle ` ] ( #setStyle ) - Modify a specified style property.
31+ [ ` setTimeout ` ] ( #setTimeout ) - Override the default timeout for dojo commands, for a specific ` uifigure ` .
32+ [ ` textAlign ` ] ( #textAlign ) - Modify text alignment.
33+ [ ` waitForFigureReady ` ] ( #waitForFigureReady ) - A blocking method that only returns after the uifigure is fully loaded.
34+
35+ -----------------
36+ <a name =" aboutJSLibs " ></a >
37+
38+ #### * mlapptools* .** aboutJSLibs** ()
39+
3340##### Description
34- Returns a ` struct ` containing version information about the Dojo toolkit loaded into the first open ` uifigure ` .
35- If no ` uifigure ` is open, a temporary window is created, queried, then closed - indicating the default Dojo version.
41+
42+ Returns a ` struct ` containing information about the [ Dojo toolkit] ( https://dojotoolkit.org/ ) and
43+ [ ReactJS] ( https://reactjs.org/ ) versions loaded into the first open ` uifigure ` .
44+ If no ` uifigure ` is open, a temporary window is created, queried, then closed - indicating the default versions.
3645
3746##### Examples
3847
39- ``` matlab
40- >> mlapptools.aboutDojo ()
48+ ``` MATLAB
49+ >> mlapptools.aboutJSLibs ()
4150
42- ans =
51+ ans =
4352
4453 struct with fields:
4554
46- major: 1
47- minor: 11
48- patch: 2
49- flag: ''
50- revision: '91fa0cb'
55+ dojo: '1.11.2.91fa0cb'
56+ react_js: '0.14.7'
5157```
5258
59+ -----------------
5360<a name =" fontColor " ></a >
61+
5462#### * mlapptools* .** fontColor** (* uiElement* , * newcolor* )
63+
5564##### Description
65+
5666Set the font color of the specified UI element, ` 'uiElement' ` , to the input color, ` newcolor ` . ` newcolor ` can be a
5767predefined color string or a string containing a valid CSS color method call.
5868
5969Valid color specifications are:
60- * Hexadecimal colors - e.g. ` '#ff0000' ` for red
61- * RGB colors - e.g. ` 'rgb(255,165,0)' ` for orange
62- * RGBA colors - e.g. ` 'rgba(255,255,0,0.3)' ` for yellow
63- * HSL colors - e.g. ` 'hsl(120, 100%, 50%)' ` for green
64- * HSLA colors - e.g. ` 'hsla(240,100%,50%, 1.0)' ` for blue
65- * Predefined color names - e.g. ` 'red' ` , ` 'orange' ` , ` 'yellow' ` , ` 'green' ` , ` 'blue' ` , ` 'indigo' ` , ` 'violet' ` .
70+
71+ - Hexadecimal colors - e.g. ` '#ff0000' ` for red
72+ - RGB colors - e.g. ` 'rgb(255,165,0)' ` for orange
73+ - RGBA colors - e.g. ` 'rgba(255,255,0,0.3)' ` for yellow
74+ - HSL colors - e.g. ` 'hsl(120, 100%, 50%)' ` for green
75+ - HSLA colors - e.g. ` 'hsla(240,100%,50%, 1.0)' ` for blue
76+ - Predefined color names - e.g. ` 'red' ` , ` 'orange' ` , ` 'yellow' ` , ` 'green' ` , ` 'blue' ` , ` 'indigo' ` , ` 'violet' ` .
6677 For more colors, see the predefined color names [ CSS color specification] ( https://www.w3.org/TR/css3-color/ ) .
6778
6879##### Examples
80+
6981Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
7082
7183``` MATLAB
@@ -78,22 +90,27 @@ myGUI = DOMdemoGUI;
7890mlapptools.fontColor(myGUI.TextArea, 'rgb(255,165,0)');
7991```
8092
81-
93+ -----------------
8294<a name =" fontWeight " ></a >
95+
8396#### * mlapptools* .** fontWeight** (* uiElement* , * weight* )
97+
8498##### Description
99+
85100Set the font weight of the specified UI element, ` uiElement ` , to the input weight string or integer, ` weight ` .
86101For this setting to have an effect, the font being used must have built-in faces that match the specified weight.
87102
88103Valid font weight property values are:
89- * ` 'normal' ` - Normal characters (default)
90- * ` 'bold' ` - Thick characters
91- * ` 'lighter' ` / ` 'bolder' ` - The closest available "lighter" or "bolder" weight, relative to the parent.
92- * ` 100 .. 900 ` - Integers mapping to ` 'normal' ` , ` 'bold' ` , etc.
104+
105+ - ` 'normal' ` - Normal characters (default)
106+ - ` 'bold' ` - Thick characters
107+ - ` 'lighter' ` / ` 'bolder' ` - The closest available "lighter" or "bolder" weight, relative to the parent.
108+ - ` 100 .. 900 ` - Integers mapping to ` 'normal' ` , ` 'bold' ` , etc.
93109 Intermediate integers (and floats) are accepted but generally map to the available values
94- * ` 'initial' ` - Revert to default
110+ - ` 'initial' ` - Revert to default
95111
96112##### Examples
113+
97114Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
98115
99116``` MATLAB
@@ -106,125 +123,163 @@ myGUI = DOMdemoGUI;
106123mlapptools.fontWeight(myGUI.TextArea, 600);
107124```
108125
109-
126+ -----------------
110127<a name =" getHTML " ></a >
128+
111129#### * mlapptools* .** getHTML** (* hUIFigure* )
130+
112131##### Description
132+
113133A method for obtaining the HTML code of a uifigure. Intended for R2017b (and onward?) where the CEF URL cannot be
114134simply opened in a browser. The returned HTML is a deep copy, meaning that any changes will ** not** modify the
115135` uifigure ` where it originated from.
116136
117137##### Examples
138+
118139Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
140+
119141``` MATLAB
120142myGUI = DOMdemoGUI;
121143fullHTML = mlapptools.getHTML(myGUI.UIFigure);
122144web(['text://' fullHTML]);
123145```
124146
125-
147+ -----------------
126148<a name =" getWebElements " ></a >
149+
127150#### * mlapptools* .** getWebElements** (* uiElement* )
151+
128152##### Description
129- A method for obtaining the webwindow handle and the widget ID corresponding to the provided ` uifigure ` control. The
153+
154+ A method for obtaining the webwindow handle and the widget ID corresponding to the provided ` uifigure ` control. The
130155widget ID can be used to call the 4-parameter variant of [ ` setStyle ` ] ( #setStyle ) .
131156
132157##### Examples
158+
133159``` MATLAB
134160myGUI = DOMdemoGUI;
135161[win, widgetID] = mlapptools.getWebElements(myGUI.TextArea);
136162```
137163
138-
164+ -----------------
139165<a name =" getWebWindow " ></a >
166+
140167#### * mlapptools* .** getWebWindow** (* hUIFigure* )
168+
141169##### Description
170+
142171A method for getting the webwindow handle associated with the provided ` uifigure ` .
143172
144173##### Examples
174+
145175Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
176+
146177``` MATLAB
147178myGUI = DOMdemoGUI;
148179win = mlapptools.getWebWindow(myGUI.UIFigure);
149180```
150181
151-
182+ -----------------
152183<a name =" getWidgetInfo " ></a >
184+
153185#### * mlapptools* .** getWidgetInfo** (* hWebwindow* , * widgetID* , * verbosityFlag* )
186+
154187##### Description
155- Query the [ dijit registry] ( https://dojotoolkit.org/reference-guide/dijit/registry.html#dijit-registry ) for a widgets
188+
189+ Query the [ dijit registry] ( https://dojotoolkit.org/reference-guide/dijit/registry.html#dijit-registry ) for a widget
156190having a specific ID, and return its details in a scalar ` cell ` containing a ` struct ` .
157191
158192##### Examples
193+
159194Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
195+
160196``` MATLAB
161197myGUI = DOMdemoGUI;
162198[win, widgetID] = mlapptools.getWebElements(myGUI.TextArea);
163199nfo = mlapptools.getWidgetInfo(win, widgetID);
164200```
165201
166-
202+ -----------------
167203<a name =" getWidgetList " ></a >
204+
168205#### * mlapptools* .** getWidgetList** (* hUIFigure* , * verbosityFlag* )
206+
169207##### Description
208+
170209Query the [ dijit registry] ( https://dojotoolkit.org/reference-guide/dijit/registry.html#dijit-registry ) for all widgets
171210within the current page, and return them in a cell array of structs.
172211
173212##### Examples
174213Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
214+
175215``` MATLAB
176216myGUI = DOMdemoGUI;
177217nfoList = mlapptools.getWidgetList(myGUI.UIFigure);
178218```
179219
180-
220+ -----------------
181221<a name =" setStyle " ></a >
222+
182223#### * mlapptools* .** setStyle** (* uiElement* , * styleAttr* , * styleValue* )
224+
225+ #### * mlapptools* .** setStyle** (* hWin* , * styleAttr* , * styleValue* , * ID_object* )
226+
183227##### Description
228+
184229Set the style attribute ` styleAttr ` of the specified UI element, ` 'uiElement' ` , to the value ` styleValue ` . ` styleAttr `
185230should be any valid CSS attribute, and ` styleValue ` a valid setting thereof.
186231
187- This method provides a general interface to change CSS style attributes, with minimal input testing and error reporting,
232+ This method provides a general interface to change CSS style attributes, with minimal input testing and error reporting,
188233so it is up to the user to provide valid inputs.
189234
190235Valid style attributes and corresponding settings can be found [ here] ( https://www.w3schools.com/cssref/ ) .
191236
192237##### Examples
238+
193239Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
240+
194241``` MATLAB
195242myGUI = DOMdemoGUI;
196243mlapptools.setStyle(myGUI.TextArea, 'background-image',...
197244 'url(https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg)');
198245```
199246
200-
247+ -----------------
201248<a name =" setTimeout " ></a >
249+
202250#### * mlapptools* .** setTimeout** (* hUIFig* )
251+
203252##### Description
253+
204254Modify the amount of time allotted to dojo queries before they are considered "failed due to timeout". This value is
205255` uifigure ` -specific. If left unmodified, the default value is ` 5 ` seconds.
206256
207257##### Examples
258+
208259``` MATLAB
209260myGUI = DOMdemoGUI;
210261mlapptools.setTimeout(myGUI.UIFigure, 3); % This will wait less for dojo queries to finish.
211262```
212263
213-
264+ -----------------
214265<a name =" textAlign " ></a >
266+
215267#### * mlapptools* .** textAlign** (* uiElement* , * alignment* )
268+
216269##### Description
217- Set the horizontal text alignment of the specified UI element, ` uiElement ` , to that specified by the input alignment
218- string, ` alignment ` .
270+ Set the horizontal text alignment of the specified UI element, ` uiElement ` , to that specified by the input alignment
271+ string, ` alignment ` .
219272
220273Valid alignment strings are:
221- * ` 'left' ` - Left align (default)
222- * ` 'center' ` - Center align
223- * ` 'right' ` - Right align
224- * ` 'justify' ` - Each line has equal width
225- * ` 'initial' ` - Revert to default
274+
275+ - ` 'left' ` - Left align (default)
276+ - ` 'center' ` - Center align
277+ - ` 'right' ` - Right align
278+ - ` 'justify' ` - Each line has equal width
279+ - ` 'initial' ` - Revert to default
226280
227281##### Examples
282+
228283Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
229284
230285``` MATLAB
@@ -235,4 +290,13 @@ mlapptools.textAlign(myGUI.TextArea, 'center');
235290``` MATLAB
236291myGUI = DOMdemoGUI;
237292mlapptools.textAlign(myGUI.TextArea, 'right');
238- ```
293+ ```
294+
295+ -----------------
296+ <a name =" waitForFigureReady " ></a >
297+
298+ #### * mlapptools* .** waitForFigureReady** (* hUIFig* )
299+
300+ ##### Description
301+
302+ This method pauses execution of further commands on the MATLAB thread until the asynchronous loading of the UIFigure and its webwindow has finished. It's good practice to use this method before starting to manipulate the styles of individual elements to avoid ` null ` widget reference errors.
0 commit comments