imshow appears to interfere with ButtonDownFcn

1 view (last 30 days)
In the following code, if ShowImage is set to false, a mouse button press causes ax_bdfcn to be called. However, if ShowImage is set to true, mouse button presses do not seem to have any impact.
function ShowButtonDownFcnIssue()
close all
ThisImage = imread( 'board.tif' ) ;
figure(1)
ShowImage = true;
if ShowImage
h=imshow( ThisImage ) ;
hold on
set(h, 'HitTest', 'off' );
end
plot( [149 136 ] , [248, 204 ] , 'c', 'LineWidth', 5, 'HitTest', 'off' );
hold on
axes_handle = gca;
set(axes_handle, 'HitTest', 'on', 'ButtonDownFcn',{@ax_bdfcn});
pause( 25 )
% call back as nested function
function ax_bdfcn(varargin)
disp('INTERRUPT')
end % close nested function
end

Answers (0)

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!