Make button down function work for objects inside axes.

조회 수: 12 (최근 30일)
Raldi
Raldi 2013년 1월 12일
Hi, I have a quick question, I am using the "WindowButtonDownFcn" in order to get the location i clicked inside an axes object, but when i click lets say in a rectangle that is plotted inside the axes i don't get that location. So how can i make this function print the location i clicked inside the axes no matter what it is plotted in it.
Should i use the "WindowButtonDownFcn" in my figure or panel that the axes belong rather than the axes itself? And wouldn't that be a problem as my axes units are set in cm?
Thank you for your time.

채택된 답변

Bilen Oytun Peksel
Bilen Oytun Peksel 2013년 2월 19일
Set hittest off for all the objects on the axis and make sure that axis off is not executed.
  댓글 수: 1
Jan
Jan 2013년 2월 19일
편집: Jan 2013년 2월 19일
And then use the ButtonDownFcn of the AXES instead of the WindowsButtonDownFcn. Finally the CurrenPoint property of the axes contains the clicked point in data units. So the axes units do not matter. Note that the CurrentPoint is stored as 2 lines as [2x3] matrix. In a 2D view:
P = get(axesHandle, 'CurrentPoint');
x = P(1,1);
y = P(1,2);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by