MATLAB Answers


Mouse Click callback on an image - temporarily disable

Asked by Jason
on 14 Aug 2019
Latest activity Commented on by Jason
on 14 Aug 2019
Hello, I have a GUI (created by guide) where everytime I load an image and display in an axes component I assign a button down function (called ImageClickCallback) so everytime I click on the image my function ImageClickallback executes. This all works fine.
imageHandle=imshow(img,[low,high]); % Display Image
set(imageHandle,'ButtonDownFcn',@ImageClickCallback); % Assign callback to ButtonDown event
I am wanting to now use a mouse click on the image to draw lines (I know how to do this) but everytime I click the image the original ImageClickCallback executes. So my question is can I pause the original ButtonDownFcn callback ?


Sign in to comment.

1 Answer

Answer by Geoff Hayes
on 14 Aug 2019
 Accepted Answer

Jason - why not just remove the original callback just prior to wanting to draw the lines
You could then restore it later when needed.


OK, have tried this:
In the function that I define image Handle
imageHandle=imshow(A,[lo hi]);
guidata(hObject, handles);
Then in the 2nd function where I want to disable the ButtonDownFcn
set(imageHandle,'ButtonDownFcn ',[]); %temporarily turn off current ButtonDown event
But I get the following error message
Error using
The property name 'ButtonDownFcn ' is not a valid MATLAB identifier.
Error in ArchimedesIQC>pushbutton199_Callback (line 15392)
set(imageHandle,'ButtonDownFcn ',[]); %temporarily turn off current ButtonDown event
The problem might be because of the trailing space character in the string
'ButtonDownFcn '
Try replacing with
Yes thts it....thanks for spotting the error

Sign in to comment.