regionZoomInteraction only works the first time, bug?

6 ビュー (過去 30 日間)
Pelajar UM
Pelajar UM 2022 年 5 月 31 日
回答済み: Rahul 2025 年 1 月 20 日 6:02
So I noticed this very weird thing which I think is a bug...
When the switch is on by default, the regionZoom works as intended. Then I turn it off, and rotate and zoom starts to work. And turn it on again, now the regionZoom cursor shows, you can select the area, but it doesn't actually zoom.
It looks like regionZoom only works in the first instance. Second time onwards it doesn't work. ZoomInteraction still works and this issue only applies to regionZoom.
Any thoughts? Can I add regionZoom as a standard option in the axes toolbar? That would do the job too.
function ButtonPushed(app, event)
ax=app.UIAxes;
if app.Switch.Value == "Off"
ax.Interactions = [rotateInteraction zoomInteraction];
else
ax.Interactions = [regionZoomInteraction zoomInteraction] ;
end

回答 (1 件)

Rahul
Rahul 2025 年 1 月 20 日 6:02
I understand that you require to change interactions while using a Switch component and Button callback in your App.
After creating a dummy app, according to the description given by you, I was able to understand the reason behind the behaviour.
According to the Limitations mentioned in the documentation of 'regionZoomInteraction', the interaction is not supported for charts in a 3-D view. Hence when the Switch component is turned 'off' and the 'rotateInteraction' is used, while rotating the axis, the plot shifts to a 3-D view. Hence when the Switch component is turned 'on' again the 'regionZoomInteraction' does not function as expected.
A possible workaround for this can be to restore to the 'Default View' of the axis by clicking the 'Home' or 'Rotate 3D' icon of the plot as shown below:
This will restore the axis to a 2D view and then the 'regionZoomInteraction' will work as expected.
Refer to the following MathWorks documentation to know more:
Thanks.

カテゴリ

Help Center および File ExchangeCreate Custom UI Components についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by