How to enable datacursormode and zoom for only one axes in a figure?

조회 수: 6 (최근 30일)
Luna
Luna 2019년 8월 28일
댓글: Luna 2019년 8월 28일
Hello dear community,
I have question about the GUI I made programatically with OOP. I am not using GUIDE or AppDesigner.
I have different tabs in my GUI and I have different plots in each tab. I created 2 selection custom uicontextmenu. When user right clicks on the axis area, a menu opens and selections are "Enable Cursor" and "Enable Zoom". I created the callback for each case which creates the data cursor object or zoom object according to user selection.
The problem is this datacursor and zoom mode became active for other plots in the other tabs, too. I only want single one become active. The reason all become active is datacursormode and zoom functions gets the figure handle as an input. So the entire figure is affected.
Also another problem when I activated zoom, the custom uicontextmenu I have created disappeared, instead it is replaced with 'PostContextMenu' which is the rightClickAction property of the zoom object. I couldn't find a way to turn it back to my custom 2 options menu again.
Do you have any ideas for my 2 problems? Any help will be appreciated.
Thanks very much! :)
  댓글 수: 1
Luna
Luna 2019년 8월 28일
편집: Luna 2019년 8월 28일
Additionally, I tried set the UIContextMenu property of zoom object to replace default context menu of zoom with my custom uicontextmenu, it gave me the below error:
The 'UIContextMenu' property may be set only when zoom is not on.
How am I supposed to use zoom when I set Enable off?

댓글을 달려면 로그인하십시오.

채택된 답변

Steven Lord
Steven Lord 2019년 8월 28일
For your first question, call setAllowAxesZoom on the zoom mode object returned by the zoom function. See the "Zoom Mode Utility Functions" section on that documentation page. I don't believe the datacursormode object offers the same functionality, but that seems like a reasonable enhancement request to send to Technical Support using the telephone icon in the upper-right corner of this page.
For your second question, try setting the UIContextMenu property of the zoom mode object to your custom uicontextmenu when the RightClickAction is set to 'PostContextMenu', or turn Enable 'off' then set your UIContextMenu and turn Enable back 'on'.
  댓글 수: 1
Luna
Luna 2019년 8월 28일
Thanks Steven, I explored the same thing as you said while turning 'off' and 'on' playing around the zoom object. So first, turned off, then set the UIContextMenu to myNewUIContexMenu object, then turned the zoom on. It perfectly worked! Also setAllowAxesZoom worked the way I wanted. Now I can turn on zoom for specific axes I choose.
Unfortunately datacursormode object doesn't have similar utility functions like zoom object has. Maybe I could try to remove UIContextMenu for the other axes that I don't want user to click.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by