
figure(gcf);
h = imshow(zeros(500));
uimenu('label', 'whatever');

function myplot(h)
     mfilename
     cp = get(gca,'CurrentPoint');
     y = cp(2);
     fprintf('Y: %f\n', y);
     im = get(h, 'cdata');
     im(round(y:y+5),:) = 1;
     set(h, 'cdata', im);
     drawnow;
end

function f2(h)
    myplot(h);
    disp('If you did not move the mouse pointer and you see two lines, there is a bug.');
     set(gcf, 'WindowButtonUpFcn', '');
end

function f1(h)
     myplot(h);
     delete(findall('type', 'uimenu'));
     disp('Please click again now in the same exact point.');
     set(gcf, 'WindowButtonUpFcn', @(~,~)f2(h));
end

set(gcf, 'WindowButtonUpFcn', @(~,~)f1(h));
disp('Please click somewhere in the middle of the black square and don''t move the mouse pointer.');
