Skip to content

Commit b7e89e5

Browse files
committed
Re-wrote the logic for handling UIAxes in different MATLAB versions
Added a limited way to get a WidgetID of uiaxes on R2020b. See also issue #28.
1 parent a68d650 commit b7e89e5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

mlapptools.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,24 @@ function fontWeight(hUIElement, weight)
308308
widgetID = arrayfun(@(x)WidgetID(mlapptools.DEF_ID_ATTRIBUTE, x), ...
309309
string(tmp.id(contains(tmp.id, TAB_PREFIX))));
310310
case 'axes'
311-
switch subsref(ver('matlab'), substruct('.','Version'))
312-
case {'9.6'} % R2019a
313-
descendType = 'img';
314-
otherwise % R2016a-R2018b
311+
switch true
312+
case verLessThan('matlab','9.0') % ver <= R2015b
313+
throw(MException('getWebElements:MATLABTooOld',...
314+
'MATLAB versions before R2016a are not supported!'));
315+
case verLessThan('matlab','9.6') % R2016a-R2018b
315316
descendType = 'canvas';
316317
% This canvas has a context of type "webgl".
317318
% See also: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API
318319
warning(['UIAxes object detected. Returning the innermost <canvas> element. '...
319320
'Be advised that mlapptools cannot modify this element, which '...
320-
'instead requires using WebGL commands via `hWin.executeJS(...)`.']);
321+
'instead requires using WebGL commands via `hWin.executeJS(...)`.']);
322+
case verLessThan('matlab','9.7') % R2019a
323+
descendType = 'img';
324+
otherwise % R2019b-????
325+
descendType = 'canvas';
326+
widgetID = mlapptools.getDecendentOfType( ...
327+
hWin, mlapptools.getDataTag(hUIElement.Parent), descendType);
328+
return
321329
end
322330
widgetID = mlapptools.getDecendentOfType( ...
323331
hWin, mlapptools.getDataTag(hUIElement), descendType);

0 commit comments

Comments
 (0)