how to use linkprop with custom interactions in appdesigner?

4 views (last 30 days)
I followed the steps here to enable linkprop between two axes in an app, which worked. However, when I try to set the Interactions, the behavior is not what I expect. If I set the Interactions to be rotateInteraction for both axes, I can click+drag to rotate axis 1 (which rotates axis 2) but I can't click+drag to rotate axis 2. If I click axis 2 first, then I can't interact with axis 1. Is this a bug or am I not doing something correctly? Thanks.
properties (Access = private)
ax1 matlab.graphics.axis.Axes
ax2 matlab.graphics.axis.Axes
hlink
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.ax1 = axes(app.Panel);
app.ax2 = axes(app.Panel2);
scatter3(app.ax1,1,1,1)
scatter3(app.ax2,1,1,1)
app.ax1.Toolbar = [];
app.ax2.Toolbar = [];
app.ax1.Interactions = [];
app.ax2.Interactions = [];
end
% Button pushed function: RotateButton
function RotateButtonPushed(app, event)
app.ax1.Interactions = [rotateInteraction];
% app.ax2.Interactions = [rotateInteraction];
app.hlink = linkprop([app.ax1,app.ax2],{'CameraUpVector', 'CameraPosition', 'CameraTarget', 'XLim', 'YLim', 'ZLim','Interactions'});
end
% Button pushed function: ZoomButton
function ZoomButtonPushed(app, event)
app.ax1.Interactions = [zoomInteraction];
% app.ax2.Interactions = [zoomInteraction];
% app.hlink = linkprop([app.ax1,app.ax2],{'CameraUpVector', 'CameraPosition', 'CameraTarget', 'XLim', 'YLim', 'ZLim','Interactions'});
end
end

Answers (1)

Kevin Holly
Kevin Holly on 2 May 2022
I was able to replicate the same issue with your code.
Is there a reason that you aren't using UIAxes? I was able to get the following to work smoothly using uiaxes in R2021b and R2022a.
linkprop([app.UIAxes,app.UIAxes2],{'CameraUpVector', 'CameraPosition', 'CameraTarget', 'XLim', 'YLim', 'ZLim','Interactions'})
  1 Comment
sigguy90
sigguy90 on 9 May 2022
Edited: sigguy90 on 9 May 2022
The thread I linked in the original post suggested using axes instead of UIAxes. With UIAxes, the interactions still don't work right. I tried changing the property definition for ax1 and ax2 but that didn't help. This is in R2021b.
properties (Access = private)
ax1
ax2
hlink
end

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!