While ButtonDownFcns are not supported for UIAxes, UIFigures do support WindowButtonDownFcns. Additionally, selecting UIAxes that are children of said UIFigure, as well as selecting children of that UIAxes will trigger the WindowButtonDownFcn for the UIFigure.
If you would like the WindowButtonDownFcn to only be triggered when a point in your line is selected, you can use a combination of an if statement and tags to only trigger the callback when the line is selected.
First when plotting your original line, you should add a tag that can be referenced later:
plot(app.UIAxes, app.Var1, 'Tag', 'allData');
Next, create a WindowButtonDownFcn for your UIFigure by right clicking on your UIFigure in the Component Browser, selecting "Callbacks" from the context menu, then selecting "WindowButtonDownFcn". Once this callback is created, you can use something similar to below to check if there is a CurrentObject selected (i.e. a line was selected and not a blank space in the either the UIFigure or UIAxes), and if the tag of that CurrentObject matches the tag of your line. Beginning in MATLAB R2019a, you can then use the CurrentPoint property of UIAxes to determine where within the UIAxes was selected. All together this would look like as follows:
function UIFigureWindowButtonDown(app, event) %Create if statement that determines if the user clicked on the %line of the top UIAxes. If they didn't, do nothing if ~isempty(event.Source.CurrentObject) && isequal(event.Source.CurrentObject.Tag,'allData')
%Store the CurrentPiont of the UIAxes as app.a app.a = app.UIAxes.CurrentPoint(1);
alpha = 200;
%Set the XLim of the bottom UIAxes to be +/- alpha of the %current point app.UIAxes2.XLim = [(app.a-alpha) (app.a+alpha)];
%Plot the data on the bottom UIAxes plot(app.UIAxes2,app.Var1) end end
NOTE: The CurrentPoint property of UIAxes was introduced in R2019a