classdef polariMBPeaksTable < internal.polariMouseBehavior
    % Peaks Table mouse behavior
    
    methods
        function obj = polariMBPeaksTable
            
            obj.InstallFcn  = @showToolTipAndPtr;
            obj.MotionEvent = @wbmotion;
            obj.DownEvent   = [];
            obj.UpEvent     = [];
            obj.ScrollEvent = [];
        end
    end
end

% Local functions
%
% - input argument "p" is a polari object, not a polariMBPeaksTable

function wbmotion(p,ev)
% If mouse is over ANY peaks table (could be multiple polari axes), we
% treat it as though we're over own own.  It is an "index-less" axes test
% in computeHoverLocation().

s = computeHoverLocation(p,ev);

% Peaks table is special since we detect mouse hits on it even when mouse
% is OUTSIDE axes area.  Because of that we need to test axes-index here.
firstEntry = p.ChangedState;
if s.overFigPanel
    if firstEntry
        % Only signal that we've completed entry if this is the right
        % instance.
        p.ChangedState = false;
        showToolTipAndPtr(p);
    end
else
    if ~firstEntry
        % Only perform these steps if this instance completed entry steps.
        autoChangeMouseBehavior(p,s);
    end
end
end

function showToolTipAndPtr(p)

%setptr(p.hFigure,'hand');
if p.ToolTips && ~isempty(p.hToolTip) && isvalid(p.hToolTip)
    start(p.hToolTip, ...
        'Right-click for options');
end
end
