function installtip(this,gobjects,tipfcn,info)
%INSTALLTIP  Installs line tip on specified G-objects.

%   Author(s): P. Gahinet
%   Copyright 1986-2004 The MathWorks, Inc.
%   $Revision: 1.1.6.3 $  $Date: 2004/12/10 19:33:27 $

% RE: TIPFCN is either '' or a MATLAB callback. The tip text is generated by evaluating the 
%     tip function according to
%        TIPTEXT = feval(@fcn,INFO,arg1,...,argN)
%     for TIPFCN = {@fcn arg1 ... argN}
if isempty(tipfcn)
   % Clear tip function
   BDF = '';
else
   BDF = {@localLineButtonDown tipfcn info};
end
set(gobjects,'ButtonDownFcn',BDF)

for ct = 1:length(gobjects)
    %% Get the behavior object
    hb = hggetbehavior(gobjects(ct),'DataCursor');
    if iscell(tipfcn)
        set(hb,'UpdateFcn',{tipfcn{1} info tipfcn{2:end}});
    else
        set(hb,'UpdateFcn',{tipfcn info});
    end
end

%%%%%%%%%%  Local Functions   %%%%%%%%%%  

function tip = localLineButtonDown(EventSrc,EventData,tipfcn,info)
% Creates data tip and sets its tip function
tip = linetip(EventSrc,info.TipOptions{:});

%% Listener for the Frequency Units of the Nichols Plot object. 
tip.addlistener(handle.listener(info.Carrier.Parent,...
                    info.Carrier.Parent.findprop('FrequencyUnits'),...
                    'PropertyPostSet',{@LocalUpdateString, tip}));

%%% Local function to update the string if the units change.
function LocalUpdateString(EventSource,EventData,tip)

tip.updatestring

