1010 end
1111 end
1212
13+
1314 methods (Static )
1415 function textAlign(uielement , alignment )
1516 alignment = lower(alignment );
@@ -60,6 +61,31 @@ function fontWeight(uielement, weight)
6061 end
6162 end
6263 end
64+
65+
66+ function fontcolor(uielement , newcolor )
67+ newcolor = mlapptools .validateCSScolor(newcolor );
68+
69+ DOMcolor = ' ' ;
70+ while ~strcmp(DOMcolor , sprintf(' "%s "' , newcolor ))
71+ try
72+ % Get a handle to the webwindow
73+ win = mlapptools .getwebwindow(uielement .Parent );
74+
75+ % Find which element of the DOM we want to edit
76+ data_tag = mlapptools .getdatatag(uielement );
77+
78+ % Manipulate the DOM via a JS command
79+ widgetID = mlapptools .getwidgetID(win , data_tag );
80+
81+ fontwtsetstr = sprintf(' dojo.style(dojo.query("#%s ")[0], "color", "%s ")' , widgetID , newcolor );
82+ DOMcolor = win .executeJS(fontwtsetstr );
83+ catch err
84+ % TODO: Check the error so we're not catching errors indiscriminately
85+ pause(1 ); % Give the figure (webpage) some more time to load
86+ end
87+ end
88+ end
6389 end
6490
6591
@@ -70,19 +96,22 @@ function fontWeight(uielement, weight)
7096 win = struct(struct(uifigurewindow ).Controller).Container.CEF;
7197 mlapptools .togglewarnings(' on' )
7298 end
73-
99+
100+
74101 function [data_tag ] = getdatatag(uielement )
75102 mlapptools .togglewarnings(' off' )
76103 data_tag = char(struct(uielement ).Controller.ProxyView.PeerNode.getId);
77104 mlapptools .togglewarnings(' on' )
78105 end
79106
107+
80108 function [widgetID ] = getwidgetID(win , data_tag )
81109 widgetquerystr = sprintf(' dojo.getAttr(dojo.query("[data-tag^=''%s'' ] > div")[0], "widgetid")' , data_tag );
82110 widgetID = win .executeJS(widgetquerystr );
83111 widgetID = widgetID(2 : end - 1 );
84112 end
85113
114+
86115 function togglewarnings(togglestr )
87116 switch lower(togglestr )
88117 case ' on'
@@ -110,6 +139,7 @@ function validatealignmentstr(alignment)
110139 end
111140 end
112141
142+
113143 function [weight ] = validatefontweight(weight )
114144 if ischar(weight )
115145 weight = lower(weight );
@@ -132,5 +162,9 @@ function validatealignmentstr(alignment)
132162 % Throw error
133163 end
134164 end
165+
166+
167+ function [newcolor ] = validateCSScolor(newcolor )
168+ end
135169 end
136170end
0 commit comments