Skip to content

Commit 112cc75

Browse files
committed
Fixed some capitalization issues and added "end % comments"
1 parent 807cbb6 commit 112cc75

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# mlapptools
2-
`mlapptools` is an example set of static MATLAB methods for manipulating the DOM underlying the App Designer UI elements formally introduced in R2016a
2+
`mlapptools` is an example set of static MATLAB methods for manipulating the DOM underlying the App Designer UI elements formally introduced in R2016a.
33

4-
For additional information, see Iliya Romm's guest Undocumented Matlab article, [*Customizing uifigures part 2*](http://undocumentedmatlab.com/blog/customizing-uifigures-part-2), published Wednesday, September 7th, 2016
4+
For additional information, see Iliya Romm's Undocumented Matlab guest article, [*Customizing uifigures part 2*](http://undocumentedmatlab.com/blog/customizing-uifigures-part-2), published Wednesday, September 7th, 2016.
55

66
## Methods
77
[`textAlign`](#textAlign) - Modify text alignment

mlapptools.m

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
methods (Access = public, Static = true)
1818
function textAlign(uielement, alignment)
1919
alignment = lower(alignment);
20-
mlapptools.validatealignmentstr(alignment)
20+
mlapptools.validateAlignmentStr(alignment)
2121

2222
[win, widgetID] = mlapptools.getWebElements(uielement);
2323

2424
alignSetStr = sprintf('dojo.style(dojo.query("#%s")[0], "textAlign", "%s")', widgetID, alignment);
2525
win.executeJS(alignSetStr);
26-
end
26+
end % textAlign
2727

2828

2929
function fontWeight(uielement, weight)
@@ -33,7 +33,7 @@ function fontWeight(uielement, weight)
3333

3434
fontWeightSetStr = sprintf('dojo.style(dojo.query("#%s")[0], "font-weight", "%s")', widgetID, weight);
3535
win.executeJS(fontWeightSetStr);
36-
end
36+
end % fontWeight
3737

3838

3939
function fontColor(uielement, newcolor)
@@ -43,7 +43,7 @@ function fontColor(uielement, newcolor)
4343

4444
fontColorSetStr = sprintf('dojo.style(dojo.query("#%s")[0], "color", "%s")', widgetID, newcolor);
4545
win.executeJS(fontColorSetStr);
46-
end
46+
end % fontColor
4747

4848

4949
function widgetID = setStyle(hControl, styleAttr, styleValue)
@@ -65,7 +65,14 @@ function fontColor(uielement, newcolor)
6565
ME = mlapptools.checkJavascriptSyntaxError(ME, styleSetStr);
6666
rethrow(ME);
6767
end
68-
end
68+
69+
% Assign outputs:
70+
if nargout >= 1
71+
varargout{1} = widgetID;
72+
end
73+
74+
end % setStyle
75+
6976
function [dojoVersion] = aboutDojo()
7077
if ~numel(matlab.internal.webwindowmanager.instance.findAllWebwindows())
7178
f=uifigure; drawnow; tmpWindowCreated = true;
@@ -89,7 +96,7 @@ function fontColor(uielement, newcolor)
8996

9097
methods (Static = true, Access = private)
9198
function [win] = getWebWindow(uifigurewindow)
92-
mlapptools.togglewarnings('off')
99+
mlapptools.toggleWarnings('off')
93100
% Test if uifigurewindow is a valid handle
94101
if ~isa(uifigurewindow,'matlab.ui.Figure') || ...
95102
isempty(struct(uifigurewindow).ControllerInfo)
@@ -113,27 +120,27 @@ function fontColor(uielement, newcolor)
113120
if strcmp(err.identifier, 'MATLAB:nonExistentField')
114121
pause(0.01)
115122
else
116-
mlapptools.togglewarnings('on')
123+
mlapptools.toggleWarnings('on')
117124
rethrow(err)
118125
end
119126
end
120127
end
121-
mlapptools.togglewarnings('on')
128+
mlapptools.toggleWarnings('on')
122129

123130
if toc >= mlapptools.QUERY_TIMEOUT
124131
msgID = 'mlapptools:getWidgetID:QueryTimeout';
125132
error(msgID, ...
126133
'WidgetID query timed out after %u seconds, UI needs more time to load', ...
127134
mlapptools.QUERY_TIMEOUT);
128135
end
129-
end
136+
end % getWebWindow
130137

131138

132139
function [data_tag] = getDataTag(uielement)
133-
mlapptools.togglewarnings('off')
140+
mlapptools.toggleWarnings('off')
134141
data_tag = char(struct(uielement).Controller.ProxyView.PeerNode.getId);
135-
mlapptools.togglewarnings('on')
136-
end
142+
mlapptools.toggleWarnings('on')
143+
end % getDataTag
137144

138145

139146
function [widgetID] = getWidgetID(win, data_tag)
@@ -150,20 +157,20 @@ function fontColor(uielement, newcolor)
150157
~isempty(strfind(err.message, 'Cannot read property ''widgetid'' of null'))
151158
pause(0.01)
152159
else
153-
mlapptools.togglewarnings('on')
160+
mlapptools.toggleWarnings('on')
154161
rethrow(err)
155162
end
156163
end
157164
end
158-
mlapptools.togglewarnings('on')
165+
mlapptools.toggleWarnings('on')
159166

160167
if toc >= mlapptools.QUERY_TIMEOUT
161168
msgID = 'mlapptools:getWidgetID:QueryTimeout';
162169
error(msgID, ...
163-
'WidgetID query timed out after %u seconds, UI needs more time to load', ...
170+
'widgetID query timed out after %u seconds, UI needs more time to load', ...
164171
mlapptools.QUERY_TIMEOUT);
165172
end
166-
end
173+
end % getWidgetID
167174

168175

169176
function [win, widgetID] = getWebElements(uielement)
@@ -175,10 +182,10 @@ function fontColor(uielement, newcolor)
175182

176183
% Manipulate the DOM via a JS command
177184
widgetID = mlapptools.getWidgetID(win, data_tag);
178-
end
185+
end % getWebElements
179186

180187

181-
function togglewarnings(togglestr)
188+
function toggleWarnings(togglestr)
182189
switch lower(togglestr)
183190
case 'on'
184191
warning on MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame
@@ -189,10 +196,10 @@ function togglewarnings(togglestr)
189196
otherwise
190197
% Do nothing
191198
end
192-
end
199+
end % toggleWarnings
193200

194201

195-
function validatealignmentstr(alignment)
202+
function validateAlignmentStr(alignment)
196203
if ~ischar(alignment)
197204
msgID = 'mlapptools:alignstring:InvalidInputIype';
198205
error(msgID, 'Expected ''%s'', inputs of type ''%s'' not supported', ...
@@ -204,10 +211,10 @@ function validatealignmentstr(alignment)
204211
msgID = 'mlapptools:alignstring:InvalidAlignmentString';
205212
error(msgID, 'Invalid string alignment specified: ''%s''', alignment);
206213
end
207-
end
214+
end % validateAlignmentStr
208215

209216

210-
function [weight] = validatefontweight(weight)
217+
function [weight] = validateFontWeight(weight)
211218
if ischar(weight)
212219
weight = lower(weight);
213220
validstrs = {'normal', 'bold', 'bolder', 'lighter', 'initial'};
@@ -229,12 +236,12 @@ function validatealignmentstr(alignment)
229236
msgID = 'mlapptools:fontWeight:InvalidFontWeight';
230237
error(msgID, 'Invalid font weight specified: ''%s''', weight);
231238
end
232-
end
239+
end % validateFontWeight
233240

234241

235242
function [newcolor] = validateCSScolor(newcolor)
236243
% TODO
237-
end
244+
end % validateCSScolor
238245

239246

240247
function ME = checkJavascriptSyntaxError(ME,styleSetStr)

0 commit comments

Comments
 (0)