how to re enable control of windowbuttondownfcn event after plotting in matlab

To re-enable the control of the WindowButtonDownFcn event after plotting in MATLAB, you simply need to set the WindowButtonDownFcn property back to the desired function or callback. Here is an example demonstrating how you can do this:

main.m
% Define a callback function for the WindowButtonDownFcn event
function myMouseCallback(src, event)
    disp('Mouse clicked!');
end

% Create a figure and set the WindowButtonDownFcn callback
fig = figure;
set(fig, 'WindowButtonDownFcn', @myMouseCallback);

% Run your plotting commands
plot(1:10, rand(1,10));

% To re-enable the control of the WindowButtonDownFcn event after plotting, you can set it back to myMouseCallback
set(fig, 'WindowButtonDownFcn', @myMouseCallback);
478 chars
15 lines

By resetting the WindowButtonDownFcn property to your desired callback function, you will regain control of the mouse click events.

related categories

gistlibby LogSnag