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.
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!