ButtonDownFcn question - different actions on different axes (using GUIDE)

조회 수: 2 (최근 30일)
Jason
Jason 2017년 3월 2일
댓글: Jason 2017년 3월 2일
Hi.
I am using a mouse down call back to plot a linescan on an image at the mouse location. This all works fine. My issue is that I only want this to happen if I am over a certain axes on my GUIDE layout (i.e. axes1). If I'm on another axes e.g axes2, then I want the mouse click to do something else.
When I display my image in axes 1 I do this:
axes(handles.axes1)
imageHandle=imshow(img,[low,high]);
set(imageHandle,'ButtonDownFcn',@ImageClickCallback); %assign to the buttondown function
I then have the ButtonDownFcn as:
function ImageClickCallback (objectHandle, eventData)
handles = guidata(objectHandle);
axesHandle=get(objectHandle,'Parent'); %Object handle is the image
coordinates=get(axesHandle,'CurrentPoint');
curX = coordinates(1,1)
curY = coordinates(1,2)
x=round(curX)
y=round(curY)
...then perform line scan
so is it possible to limit this mouseclick action just to the axes 1
axes(handles.axes1);
And how would I go about creating another function that operates on axes 2 when I press the mouse button
Thanks Jason
  댓글 수: 4
Adam
Adam 2017년 3월 2일
편집: Adam 2017년 3월 2일
Yep. Most objects have their own ButtonDownFcn.
If you want to do things with mouse motion it is more difficult as only the Figure has a callback for that, but for button clicks you can be very specific.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by