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

2 visualizaciones (últimos 30 días)
Jason
Jason el 2 de Mzo. de 2017
Comentada: Jason el 2 de Mzo. de 2017
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 comentarios
Adam
Adam el 2 de Mzo. de 2017
Editada: Adam el 2 de Mzo. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by