Change the mouse pointer while hovering above the axes.

조회 수: 11 (최근 30일)
Dhanya
Dhanya 2017년 2월 27일
댓글: Scott MacKenzie 2020년 2월 16일
Hi, We are having a MATLAB based application that allows user to select a particular point on the axes for an inbuilt feature. Enabling this feature changes the mouse pointer to a crosshair that allows the user to select a point inside the axes. With the current implementation, the pointer changes to crosshair as soon as we enable this feature (by clicking a push button in the toolbar). We want to change the implementation in such a way that the pointer changes to crosshair only when the mouse pointer is inside the axes. we are looking for a behavior similar to the zoom action of mat lab where the mouse pointer turns to a zoom icon when the current position is inside the axes.
I tried to implement this using the WindowButtonMotionFcn listener of the figure and using the overobj('axes'); method. Unfortunately this does not work for us because in our case the axes is placed in an uipanel which is then placed inside the figure. Since the axes is placed in the uipanel, overobj(axes) does not find the axes as mentioned here: http://undocumentedmatlab.com/blog/undocumented-mouse-pointer-functions
I was wondering how the zoom functionality of mat lab works - so that we could apply the same logic here. Could you be able to help us identify how the zoom functionality adjusts the mouse pointer when inside and outside the axes/draw able area?
Thank you, Dhanya
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2020년 2월 16일
Using iptPointerManager and iptSetPointerBehaviour partially works for me. There is a cross for the pointer, but the long crosshairs traversing the screen horizontally and vertically are still there as well. I want a cross for a pointer, but do not want the default crosshairs. Is there a way to remove the crosshair lines and just have the specified pointer (e.g., a cross)?

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

채택된 답변

Josh
Josh 2017년 2월 28일
편집: Walter Roberson 2019년 11월 26일
Have you tried using iptPointerManager? It allows you do define pointer behavior when the mouse enters/traverses/exits a graphics object. Here's a brief description:
% Create and activate a pointer manager for the figure:
iptPointerManager(hFigure, 'enable');
% Have the pointer change to a cross when the mouse enters an axes object:
iptSetPointerBehavior(hAxes, @(hFigure, currentPoint)set(hFigure, 'Pointer', 'cross'));
You can also set custom behavior for when the mouse moves across or exits a graphics object.
  댓글 수: 3
mcg
mcg 2018년 8월 27일
I can't get this method to work with pcshow() inside of guide. The mouse pointer always turns to the rotation symbol.
Walter Roberson
Walter Roberson 2018년 8월 27일
pcshow() creates its own controls, including setting the pointer.
You would have to set the WindowButtonMotionFcn callback of the figure after calling pcshow() in order to override what pcshow() does. It would not be enough to change the pointer once after calling pcshow(), as the WindowButtonMotionFcn changes the pointer every time it is invoked (unless the pointer happens to be set to 'custom')

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by