Trying to find a way to use the Zoom in/out tools on a figure to automatically update fields in my app.
My main problem is that I need a event that triggers the fields to be updated. I could use a button to pull the new axis limits but I feel like there should be way around that. Does anybody know how I can detect a change in the figure axis without manually pulling update figure axis?
Thanks to Oro777 for pointing me in the right direction. Here is the solution I came up with. After the figure I want this functionality applied to is created I add
z = zoom;
z.ActionPostCallback = {@ZoomPostCallback,app};
z.Enable = 'on';
Where ZoomPostCallback is
function ZoomPostCallback(~,evd,app)
%Pull new x axes limits and apply them to app edit fields
xLim = evd.Axes.XLim;
app.TimeMinsEditField.Value = round(xLim(1),2);
app.TimeMaxsEditField.Value = round(xLim(2),2);
%Pull new y axes limits and apply them to app edit fields
yLim = evd.Axes.YLim;
app.FreqMinHzEditField.Value = round(yLim(1));
app.FreqMaxHzEditField.Value = round(yLim(2));
%Run changesAxes to ensure all other fields are updated
changeAxes(app)
end
It works really well. Hope this can help somebody else down the line. It all really hindges on the fact that zoom has the pre and post callback functionality.