|
3 | 3 | % |
4 | 4 | % MLAPPTOOLS methods: |
5 | 5 |
|
| 6 | + properties |
| 7 | + % TODO: Move generic portions of repeated dojo query strings here |
| 8 | + % to reduce copypasta errors as the number of methods expands |
| 9 | + end |
| 10 | + |
6 | 11 | methods |
7 | 12 | function obj = mlapptools |
8 | 13 | % Dummy constructor so we don't return an empty class instance |
|
11 | 16 | end |
12 | 17 |
|
13 | 18 | methods (Static) |
14 | | - function alignstring(uielement, alignment) |
| 19 | + function textAlign(uielement, alignment) |
15 | 20 | alignment = lower(alignment); |
16 | 21 | mlapptools.validatealignmentstr(alignment) |
17 | 22 | mlapptools.togglewarnings('off') |
18 | 23 |
|
19 | 24 | rez = ''; |
20 | 25 | while ~strcmp(rez, sprintf('"%s"', alignment)) |
21 | 26 | try |
22 | | - % 1. Get a handle to the webwindow: |
| 27 | + % Get a handle to the webwindow |
23 | 28 | win = struct(struct(uielement.Parent).Controller).Container.CEF; |
24 | | - % 2. Find which element of the DOM we want to edit (as before): |
| 29 | + |
| 30 | + % Find which element of the DOM we want to edit |
25 | 31 | data_tag = char(struct(uielement).Controller.ProxyView.PeerNode.getId); |
26 | | - % 3. Manipulate the DOM via a JS command |
27 | | - JSstr = sprintf('dojo.style(dojo.query("[data-tag^=''%s'']")[0], "textAlign", "%s")', ... |
28 | | - data_tag, alignment); |
29 | | - rez = win.executeJS(JSstr); |
| 32 | + |
| 33 | + % Manipulate the DOM via a JS command |
| 34 | + widgetquerystr = sprintf('dojo.getAttr(dojo.query("[data-tag^=''%s''] > div")[0], "widgetid")', data_tag); |
| 35 | + widgetID = win.executeJS(widgetquerystr); |
| 36 | + widgetID = widgetID(2:end-1); |
| 37 | + |
| 38 | + alignsetstr = sprintf('dojo.style(dojo.query("#%s")[0], "textAlign", "%s")', widgetID, alignment); |
| 39 | + rez = win.executeJS(alignsetstr); |
30 | 40 | catch |
31 | | - % TODO: See if an infinite loop condition is possible |
32 | 41 | pause(1); % Give the figure (webpage) some more time to load |
33 | 42 | end |
34 | 43 | end |
|
0 commit comments