How to register mouse clicks when a image object is created
Afficher commentaires plus anciens
Hi, I've been trying to create a GUI which displays an image and asks the user the identify a point on that image. However once the image is created my button down callbacks stop triggering.
The code I'm using prior to asking the user to identify a point is:
HC=get(handles.acp_wind,'Children');
[m,~]=size(HC);
for i=1:m
set(HC(i),'HitTest','off')
end
after that I use the ButtonDownFcn of acp_wind, which is an axes object, to trigger on each mouse click and get the current point. Unfortunately the ButtonDownFcn doesn't trigger on mouse clicks once the image is created but works fine without an image. i've also tried triggering the function whenever the user clicks inside the GUI window by using:
set(gcf,'WindowButtonDownFcn',@acp_wind_ButtonDownFcn)
But again this callback stops registering when the image object is created.
Any Ideas what I'm doing wrong?
Edit: I've also tried setting the ButtonDownFcn of the image object to trigger the acp_wind_ButtonDownFcn fucntion using:
BD=get(handles.acp_wind,'ButtonDownFcn');
set(HC,'ButtonDownFcn',BD)
3 commentaires
Walter Roberson
le 30 Juil 2012
Side note: you can rewrite your code as
set( get(handles.acp_wind,'Children'), 'HitTest', 'off' );
Image Analyst
le 30 Juil 2012
Sean de Wolski
le 30 Juil 2012
What didn't work with:
BD=get(handles.acp_wind,'ButtonDownFcn');
set(HC,'ButtonDownFcn',BD)
This looks like the approach I would take. Then instead of creating a new image object, just change the 'cdata' of the current image.
Réponse acceptée
Plus de réponses (3)
Catégories
En savoir plus sur Images dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!