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

2 views (last 30 days)
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 Comments
Adam
Adam on 2 Mar 2017
Edited: Adam on 2 Mar 2017
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.

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!