Skip to content

Commit d7e065b

Browse files
committed
Added a 4-parameter overload to setStyle
- Improved in-code documentation for some methods.
1 parent 112cc75 commit d7e065b

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

mlapptools.m

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
methods (Access = public, Static = true)
1818
function textAlign(uielement, alignment)
19+
% A method for manipulating text alignment.
1920
alignment = lower(alignment);
2021
mlapptools.validateAlignmentStr(alignment)
2122

@@ -27,6 +28,8 @@ function textAlign(uielement, alignment)
2728

2829

2930
function fontWeight(uielement, weight)
31+
% A method for manipulating font weight, which controls how thick or
32+
% thin characters in text should be displayed.
3033
weight = mlapptools.validatefontweight(weight);
3134

3235
[win, widgetID] = mlapptools.getWebElements(uielement);
@@ -37,6 +40,7 @@ function fontWeight(uielement, weight)
3740

3841

3942
function fontColor(uielement, newcolor)
43+
% A method for manipulating text color.
4044
newcolor = mlapptools.validateCSScolor(newcolor);
4145

4246
[win, widgetID] = mlapptools.getWebElements(uielement);
@@ -45,16 +49,36 @@ function fontColor(uielement, newcolor)
4549
win.executeJS(fontColorSetStr);
4650
end % fontColor
4751

52+
function varargout = setStyle(varargin)
53+
% A method providing an interface for modifying style attributes of uicontrols.
54+
%
55+
% WARNING: Due to the large amount of available style attributes and
56+
% corresponding settings, input checking is not performed. As this
57+
% might lead to unexpected results or errors - USE AT YOUR OWN RISK!
58+
%
59+
% "Overloads":
60+
% 3-parameter call:
61+
% widgetID = setStyle(hControl, styleAttr, styleValue)
62+
% 4-parameter call:
63+
% setStyle(hUIFig, styleAttr, styleValue, widgetID)
4864

49-
function widgetID = setStyle(hControl, styleAttr, styleValue)
50-
% This method provides a simple interface for modifying style attributes
51-
% of uicontrols.
52-
%
53-
% WARNING: Due to the large amount of available style attributes and
54-
% corresponding settings, input checking is not performed. As this
55-
% might lead to unexpected results or errors - USE AT YOUR OWN RISK!
56-
[win, widgetID] = mlapptools.getWebElements(hControl);
65+
% Unpack inputs:
66+
styleAttr = varargin{2};
67+
styleValue = varargin{3};
5768

69+
switch nargin
70+
case 3
71+
hControl = varargin{1};
72+
% Get a handle to the webwindow
73+
[win, widgetID] = mlapptools.getWebElements(hControl);
74+
case 4
75+
hUIFig = varargin{1};
76+
widgetID = varargin{4};
77+
78+
% Get a handle to the webwindow
79+
win = mlapptools.getWebWindow(hUIFig);
80+
end
81+
5882
styleSetStr = sprintf('dojo.style(dojo.query("#%s")[0], "%s", "%s")', widgetID, styleAttr, styleValue);
5983
% ^ this might result in junk if widgetId=='null'.
6084
try
@@ -74,6 +98,8 @@ function fontColor(uielement, newcolor)
7498
end % setStyle
7599

76100
function [dojoVersion] = aboutDojo()
101+
% A method for getting version info about the Dojo Toolkit version visible by MATLAB.
102+
77103
if ~numel(matlab.internal.webwindowmanager.instance.findAllWebwindows())
78104
f=uifigure; drawnow; tmpWindowCreated = true;
79105
else

0 commit comments

Comments
 (0)