Reputation: 93
I think my issue is I don't know how to access guiel.hAX(3)
property in my button callback function where I put kiddies = get(guiel.hAX(3),'Children');
I got the error:
Undefined variable "guiel" or class "guiel.hAX".
Error in showTF/callback_update_model (line 508)
kiddies = get(guiel.hAX(3),'Children');
My nested function for button callback:
function callback_update_model(~,~)
vars.dropheight = str2num(get(edit(2),'String'));
vars.armradius = str2num(get(edit(1),'String'));
kiddies = get(guiel.hAX(3),'Children');
delete(kiddies);
clear kiddies;
set(guiel.tfPanel,'Visible','off','Position',cnst.tfPanelpos);
set(guiel.hAX(1),'Position',cnst.axpos1);
if ishandle(guiel.hAX(2))
set(guiel.hAX(2),'Position',cnst.axpos2);
end
eval(get(guiel.hPB(4),'Callback'));
end
I initialize variables in other mfile
guiel.hAX(1) = -1;
guiel.hAX(2) = -1;
guiel.hAX(3) = -1;
guiel.tfPanel = -1;
...
guiel.hAX(3) = axes('Parent',guiel.tfPanel,'Color',cnst.OFFWHITE,'Layer',...
'top','Xlim',[0 1],'YLim',[0 1],'GridLineStyle','none','Units','Normalized',...
'XTick',[],'YTick',[],'Box','off','Visible','off','Position',cnst.axpos3);
Upvotes: 0
Views: 48
Reputation: 667
To make data available in callbacks, you can store the data in the UserData property of the figure. If your figure handle is h_fig, then you would use code like this to store the data in the figure:
set(h_fig, 'UserData', guiel)
In your callback, you can use the gcbo function to get the handle to the figure, then extract the user data, use code like this:
[~, h_fig] = gcbo;
guiel = get(h_fig, 'UserData')
Upvotes: 1