Need help for Zoom function in AppDesigner

6 次查看(过去 30 天)
I know, the zoom for UIAxes only works like zoom(app.UIAxes, 'on'/'off'); I want to use a function (@updateDateLabel) after zoom operaion is performed. So, the only way to this is by using z = zoom(UIFigure), and in AppDesigner it's not working.
z = zoom(figH);
p = pan(figH);
d = datacursormode(figH);
set(z,'ActionPostCallback',@updateDateLabel);
set(p,'ActionPostCallback',@updateDateLabel);
set(d,'UpdateFcn',@dateTip);
Same is the case for pan.

回答(1 个)

Deepak
Deepak 2024-11-5,10:40
In App designer, handling events like pan and zoom can be a bit different from working with traditional figure windows. The zoom and pan functions do not support the traditional callbacks directly, so we can use “ActionPostCallback” property to define callback to these functions. This way, we can call the “updateDateLabel” function post callback of zoom and pan objects.
Here is the App Designer code to achieve the same:
figH = app.UIFigure;
% Create zoom and pan objects
z = zoom(figH);
p = pan(figH);
% Set the ActionPostCallback for zoom and pan
set(z, 'ActionPostCallback', @(src, event) updateDateLabel(app, src, event));
set(p, 'ActionPostCallback', @(src, event) updateDateLabel(app, src, event));
% Define your updateDateLabel function within the app
methods (Access = private)
function updateDateLabel(app, src, event)
% Your custom function code here
disp('Zoom or pan action completed');
% Update your UI components or perform other actions
end
end
Please find attached the documentation of App Designer Callbacks for reference:
I hope this assists in resolving the issue.

类别

Help CenterFile Exchange 中查找有关 Data Exploration 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by