ToolBar button errors after first OnCallback press

Hello folks,
The details:
  • MS windows 10 install of ML R2018b, recently upgraded from R2015b
  • gui application troubleshooting of OnCallBack/OffCallBack errors with linkaxes and zoomin/zoomout
  • switch-case-otherwise code block where errors are triggered, is pasted at the bottom.
This issue arose recently in a friend's multi-channel, mechanical vibration analysis gui. I am new to working on bugs for him, and returning to working on ML after a couple years away; so I will do my best to describe the bug I'm trying to fix.
Prior to the R2018b upgrade, no errors occurred during runtime with the linkaxes and zoom buttons on the GUI toolbar. I indicated it is customized, above, because the default toolbar buttons were deleted, then only those of use for the GUI functions were added back in (zoom out all, zoom in, zoom out, linkx, linky, pan, and datatips). All buttons work as required/expected during runtime.
The issue:
If the user clicks on either linkx or linky, then zoomin/zoomout, etc., everything works fine. However, if a user clicks off the linkx/linky, an error is generated, ie going from OnCallBack to OffCallBack. For every additional button-click, CallBack state change, the same error is generated. I've pasted in the errors:
Error using get
Cannot find 'get' method for matlab.graphics.internal.LinkAxes class.
Error in psZoom (line 58)
lprops=get(clink,'PropertyNames');%-Uses ML7.1 zoom properties
Error while evaluating ToggleTool OffCallback.
With additional clicks on the linkx/linky buttons to switch state again, the GUI performs the tasks, and generates a similar error, so it's not catastrophic. There is some sort of error handling with use of "get" for the linkaxes commands...
Error using get
Cannot find 'get' method for matlab.graphics.internal.LinkAxes class.
Error in psZoom (line 77)
lprops=get(clink,'PropertyNames');%-Uses ML7.1 zoom properties
Error while evaluating ToggleTool OnCallback.
I am looking at changes to the get command, and toggletool functions between R2015b and R2018b, but nothing is an obvious trigger of the error; so other sets of eyes/opinions are appreciated. Hopefully I've provided enough information.
Thanks,
Patrick
Code block:
out='';
hF=gcf;
hm=gcbo;
hmParent=get(hm,'Parent');
pType=get(hmParent,'Type');
switch lower(action)
case 'getstate'
if zoom(hF,'IsOn')
zc=zoom(hF,'Constraint');
switch lower(zc)
case 'horizontal'
out='xon';
case 'vertical'
out='yon';
case 'none'
out='on';
end
else
out='off';
end
return
case {'on','xon','yon','off'}
zoom(action);
case 'linkx'
ha=findobj(hF,'Tag','psAxes');
KEY = 'graphics_linkaxes';
clink=getappdata(ha(1),KEY);
lprops=get(clink,'PropertyNames');%-Uses ML7.1 zoom properties
switch arg1
case 'on'
if any(strcmp('YLim',lprops))%-Y axes are linked set to 'xy'
linkaxes(ha,'xy');
else
linkaxes(ha,'x');%-Otherwise set to 'x'
end
case 'off'
if any(strcmp('YLim',lprops))%-Y axes are linked set to 'y'
linkaxes(ha,'y');
else
linkaxes(ha,'off');%-Otherwise set to off
end
end
case 'linky'
ha=findobj(hF,'Tag','psAxes');
KEY = 'graphics_linkaxes';
clink=getappdata(ha(1),KEY);
lprops=get(clink,'PropertyNames');%-Uses ML7.1 zoom properties
switch arg1
case 'on'
if any(strcmp('XLim',lprops))%-X axes are linked set to 'xy'
linkaxes(ha,'xy');
else
linkaxes(ha,'y');%-Otherwise set to 'y'
end
case 'off'
if any(strcmp('XLim',lprops))%-Y axes are linked set to 'x'
linkaxes(ha,'x');
else
linkaxes(ha,'off');%-Otherwise set to off
end
end

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by