% Convert current
% Test As:
%
% plot(1:50, peaks(50))
% hoverlines(gca);
%
% takes one or zero arguments
otherwise,
error('
bad args'
);
end
% get figure
% get all line children of the axes
return
end
% set hover behavior
% reset all sitting
d.sit();
end
set(fig,'
windowButtonMotionFcn',@hover
) end
%%
function hover(fig, ignore)
% click
rob = java.awt.Robot();
rob.mousePress(java.awt.event.InputEvent.BUTTON1_MASK);
rob.mouseRelease(java.awt.event.InputEvent.BUTTON1_MASK);
% get object under cursor
hovering =
get(fig,'
currentObject'
);
% return if hovering over same object
lastone =
get(gca,'
userdata'
);
if hovering == lastone, return; end
% get behavior data
hData =
get(hovering,'
userdata'
);
% hovering over some other type of object perhaps
if ~isfield( hData, 'sit' ), return; end
% ok, stand up
hData.stand();
% sit-down previous
hData =
get(lastone,'
userdata'
);
hData.sit();
% store as lastone
end
%% Set hover behavior
function setbehavior( hs )
for h = hs(:)'
dim(2) = 0.1;
dim(3) = 0.9;
,'color', dim ...
,'linewidth', 1 ...
... ,'marker', 'none' ...
);
hov.
stand = @
() set(h
... ,'color', high ...
,'linewidth', 2 ...
... ,'marker', '*' ...
);
end
end