Mouse Down Function doesn't work
Show older comments
I would like to display 'abc' string on command window whenever I click somewhere in a graphic on an axis.
I searched MouseButtonFnc in doc and it says like, "Executes whenever you press a mouse button while the pointer is within the axes, but not over another graphics object."
So, how can I use MouseButtonFnc, clicking somewhere in the picture?
I used imshow function to display a picture on axes1 control.
My code is like this.
I added set(handles.axes1, 'ButtonDownFcn', @axes1_ButtonDownFcn); in Opening Function. And I tried executing "disp('abc')" in axes1_ButtonDownFcn but it didn't work.
Can I please get some advice for this?
Accepted Answer
More Answers (1)
Jan
on 16 Oct 2013
1 vote
As Yannick has explained already, the image catches the click event and therefore the axes does not see it anymore. You can eitehr use the ButtonDownFcn of the image, of disable the catching of click events by setting the image's 'HitTest' property to 'off'.
Categories
Find more on Interactive Control and Callbacks 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!