Skip to content

Commit 3267a8f

Browse files
committed
Relocated "figFromWebwindow" and explained what it does.
1 parent 4761225 commit 3267a8f

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

mlapptools.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,20 @@ function textAlign(uiElement, alignment)
333333
data_tag = char(struct(uiElement).Controller.ProxyView.PeerNode.getId);
334334
warning(warnState);
335335
end % getDataTag
336-
336+
337+
function hFig = figFromWebwindow(hWebwindow)
338+
% Using this method is discouraged as it's relatively computation-intensive.
339+
% Since the figure handle is not a property of the webwindow or its children
340+
% (to our best knowledge), we must list all figures and check which of them
341+
% is associated with the input webwindow.
342+
hFigs = findall(groot, 'Type', 'figure');
343+
warnState = mlapptools.toggleWarnings('off');
344+
hUIFigs = hFigs(arrayfun(@(x)isstruct(struct(x).ControllerInfo), hFigs));
345+
ww = arrayfun(@mlapptools.getWebWindow, hUIFigs);
346+
warning(warnState); % Restore warning state
347+
hFig = hFigs(hWebwindow == ww);
348+
end % figFromWebwindow
349+
337350
function [widgetID] = getWidgetID(win, data_tag)
338351
widgetquerystr = sprintf('dojo.getAttr(dojo.query("[data-tag^=''%s''] > div")[0], "widgetid")', data_tag);
339352

@@ -447,15 +460,6 @@ function validateAlignmentStr(alignment)
447460
end
448461
end % validateFontWeight
449462

450-
function hFig = figFromWebwindow(hWebwindow)
451-
% Using this method is discouraged.
452-
hFigs = findall(groot, 'Type', 'figure');
453-
warnState = mlapptools.toggleWarnings('off');
454-
hUIFigs = hFigs(arrayfun(@(x)isstruct(struct(x).ControllerInfo), hFigs));
455-
ww = arrayfun(@mlapptools.getWebWindow, hUIFigs);
456-
warning(warnState); % Restore warning state
457-
hFig = hFigs(hWebwindow == ww);
458-
end % figFromWebwindow
459463

460464
end % Private Static Methods
461465

0 commit comments

Comments
 (0)