1
1
![ Minimum Version] ( https://img.shields.io/badge/Requires-R2016a%20%28v9.0%29%20or%20newer-orange.svg )
2
2
3
3
# 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.
6
4
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 ) ,
9
10
published Wednesday, September 7th, 2016.
10
11
11
12
#### 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
13
15
[ open an issue] ( https://github.com/StackOverflowMATLABchat/mlapptools/issues ) in the repository.
14
16
- 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 -
16
18
[ ` matlab-app-designer ` tag on Stack Overflow] ( https://stackoverflow.com/questions/tagged/matlab-app-designer ) .
17
-
19
+
18
20
## 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
+
33
40
##### 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.
36
45
37
46
##### Examples
38
47
39
- ``` matlab
40
- >> mlapptools.aboutDojo ()
48
+ ``` MATLAB
49
+ >> mlapptools.aboutJSLibs ()
41
50
42
- ans =
51
+ ans =
43
52
44
53
struct with fields:
45
54
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'
51
57
```
52
58
59
+ -----------------
53
60
<a name =" fontColor " ></a >
61
+
54
62
#### * mlapptools* .** fontColor** (* uiElement* , * newcolor* )
63
+
55
64
##### Description
65
+
56
66
Set the font color of the specified UI element, ` 'uiElement' ` , to the input color, ` newcolor ` . ` newcolor ` can be a
57
67
predefined color string or a string containing a valid CSS color method call.
58
68
59
69
Valid 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' ` .
66
77
For more colors, see the predefined color names [ CSS color specification] ( https://www.w3.org/TR/css3-color/ ) .
67
78
68
79
##### Examples
80
+
69
81
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
70
82
71
83
``` MATLAB
@@ -78,22 +90,27 @@ myGUI = DOMdemoGUI;
78
90
mlapptools.fontColor(myGUI.TextArea, 'rgb(255,165,0)');
79
91
```
80
92
81
-
93
+ -----------------
82
94
<a name =" fontWeight " ></a >
95
+
83
96
#### * mlapptools* .** fontWeight** (* uiElement* , * weight* )
97
+
84
98
##### Description
99
+
85
100
Set the font weight of the specified UI element, ` uiElement ` , to the input weight string or integer, ` weight ` .
86
101
For this setting to have an effect, the font being used must have built-in faces that match the specified weight.
87
102
88
103
Valid 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.
93
109
Intermediate integers (and floats) are accepted but generally map to the available values
94
- * ` 'initial' ` - Revert to default
110
+ - ` 'initial' ` - Revert to default
95
111
96
112
##### Examples
113
+
97
114
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
98
115
99
116
``` MATLAB
@@ -106,125 +123,163 @@ myGUI = DOMdemoGUI;
106
123
mlapptools.fontWeight(myGUI.TextArea, 600);
107
124
```
108
125
109
-
126
+ -----------------
110
127
<a name =" getHTML " ></a >
128
+
111
129
#### * mlapptools* .** getHTML** (* hUIFigure* )
130
+
112
131
##### Description
132
+
113
133
A method for obtaining the HTML code of a uifigure. Intended for R2017b (and onward?) where the CEF URL cannot be
114
134
simply opened in a browser. The returned HTML is a deep copy, meaning that any changes will ** not** modify the
115
135
` uifigure ` where it originated from.
116
136
117
137
##### Examples
138
+
118
139
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
140
+
119
141
``` MATLAB
120
142
myGUI = DOMdemoGUI;
121
143
fullHTML = mlapptools.getHTML(myGUI.UIFigure);
122
144
web(['text://' fullHTML]);
123
145
```
124
146
125
-
147
+ -----------------
126
148
<a name =" getWebElements " ></a >
149
+
127
150
#### * mlapptools* .** getWebElements** (* uiElement* )
151
+
128
152
##### 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
130
155
widget ID can be used to call the 4-parameter variant of [ ` setStyle ` ] ( #setStyle ) .
131
156
132
157
##### Examples
158
+
133
159
``` MATLAB
134
160
myGUI = DOMdemoGUI;
135
161
[win, widgetID] = mlapptools.getWebElements(myGUI.TextArea);
136
162
```
137
163
138
-
164
+ -----------------
139
165
<a name =" getWebWindow " ></a >
166
+
140
167
#### * mlapptools* .** getWebWindow** (* hUIFigure* )
168
+
141
169
##### Description
170
+
142
171
A method for getting the webwindow handle associated with the provided ` uifigure ` .
143
172
144
173
##### Examples
174
+
145
175
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
176
+
146
177
``` MATLAB
147
178
myGUI = DOMdemoGUI;
148
179
win = mlapptools.getWebWindow(myGUI.UIFigure);
149
180
```
150
181
151
-
182
+ -----------------
152
183
<a name =" getWidgetInfo " ></a >
184
+
153
185
#### * mlapptools* .** getWidgetInfo** (* hWebwindow* , * widgetID* , * verbosityFlag* )
186
+
154
187
##### 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
156
190
having a specific ID, and return its details in a scalar ` cell ` containing a ` struct ` .
157
191
158
192
##### Examples
193
+
159
194
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
195
+
160
196
``` MATLAB
161
197
myGUI = DOMdemoGUI;
162
198
[win, widgetID] = mlapptools.getWebElements(myGUI.TextArea);
163
199
nfo = mlapptools.getWidgetInfo(win, widgetID);
164
200
```
165
201
166
-
202
+ -----------------
167
203
<a name =" getWidgetList " ></a >
204
+
168
205
#### * mlapptools* .** getWidgetList** (* hUIFigure* , * verbosityFlag* )
206
+
169
207
##### Description
208
+
170
209
Query the [ dijit registry] ( https://dojotoolkit.org/reference-guide/dijit/registry.html#dijit-registry ) for all widgets
171
210
within the current page, and return them in a cell array of structs.
172
211
173
212
##### Examples
174
213
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
214
+
175
215
``` MATLAB
176
216
myGUI = DOMdemoGUI;
177
217
nfoList = mlapptools.getWidgetList(myGUI.UIFigure);
178
218
```
179
219
180
-
220
+ -----------------
181
221
<a name =" setStyle " ></a >
222
+
182
223
#### * mlapptools* .** setStyle** (* uiElement* , * styleAttr* , * styleValue* )
224
+
225
+ #### * mlapptools* .** setStyle** (* hWin* , * styleAttr* , * styleValue* , * ID_object* )
226
+
183
227
##### Description
228
+
184
229
Set the style attribute ` styleAttr ` of the specified UI element, ` 'uiElement' ` , to the value ` styleValue ` . ` styleAttr `
185
230
should be any valid CSS attribute, and ` styleValue ` a valid setting thereof.
186
231
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,
188
233
so it is up to the user to provide valid inputs.
189
234
190
235
Valid style attributes and corresponding settings can be found [ here] ( https://www.w3schools.com/cssref/ ) .
191
236
192
237
##### Examples
238
+
193
239
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
240
+
194
241
``` MATLAB
195
242
myGUI = DOMdemoGUI;
196
243
mlapptools.setStyle(myGUI.TextArea, 'background-image',...
197
244
'url(https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg)');
198
245
```
199
246
200
-
247
+ -----------------
201
248
<a name =" setTimeout " ></a >
249
+
202
250
#### * mlapptools* .** setTimeout** (* hUIFig* )
251
+
203
252
##### Description
253
+
204
254
Modify the amount of time allotted to dojo queries before they are considered "failed due to timeout". This value is
205
255
` uifigure ` -specific. If left unmodified, the default value is ` 5 ` seconds.
206
256
207
257
##### Examples
258
+
208
259
``` MATLAB
209
260
myGUI = DOMdemoGUI;
210
261
mlapptools.setTimeout(myGUI.UIFigure, 3); % This will wait less for dojo queries to finish.
211
262
```
212
263
213
-
264
+ -----------------
214
265
<a name =" textAlign " ></a >
266
+
215
267
#### * mlapptools* .** textAlign** (* uiElement* , * alignment* )
268
+
216
269
##### 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 ` .
219
272
220
273
Valid 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
226
280
227
281
##### Examples
282
+
228
283
Using the demo GUI generated by ` ./Demo/DOMdemoGUI.m `
229
284
230
285
``` MATLAB
@@ -235,4 +290,13 @@ mlapptools.textAlign(myGUI.TextArea, 'center');
235
290
``` MATLAB
236
291
myGUI = DOMdemoGUI;
237
292
mlapptools.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