You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tooltipcallback.m
    path of file: ./repos/spinw/swfiles/+swplot
    
    the code of the file until where you have to start completion: function tooltipcallback(obj,hit,hFigure,hTransform)
% callback for displaying tooltip
% 
% ### Syntax
% 
% `swplot.tooltipcallback(obj,hit,hFigure,hTransform)`
% 
% ### Description
% 
% `swplot.tooltipcallback(obj,hit,hFigure,hTransform)` is the callback
% function that is automatically added to any object on an [swplot] figure
% that is created using one of the `swplot.plot...` commands with `tooltip`
% parameter set to `true`.
% 
% ### Input Arguments
% 
% `obj`
% : [spinw] object.

    
function tooltipcallback(obj,hit,hFigure,hTransform)
% callback for displaying tooltip
% 
% ### Syntax
% 
% `swplot.tooltipcallback(obj,hit,hFigure,hTransform)`
% 
% ### Description
% 
% `swplot.tooltipcallback(obj,hit,hFigure,hTransform)` is the callback
% function that is automatically added to any object on an [swplot] figure
% that is created using one of the `swplot.plot...` commands with `tooltip`
% parameter set to `true`.
% 
% ### Input Arguments
% 
% `obj`
% : [spinw] object.
% 
% `hit`
% :  Hit object, defines the point where the mouse clicked.
% 
% `hFigure`
% : Handle of parent swplot figure.
% 
% `hTransform`
% : Parent [matlab.hgtransform] object if exists.
% 
% ### See Also
% 
% [swplot.tooltip]
%

if isappdata(obj,'facenumber')
    % face patch object
    % convert face into object index
    fIdx = swplot.patchfacefcn(obj,hit,[],'all',[1e-7 1e-7],hTransform);
    
    if ~isempty(fIdx)
        fn   = getappdata(obj,'facenumber');
        % object number
        number = fn(fIdx(1));
        
        % graphical object data on swplot figure
        sObject = getappdata(hFigure,'objects');
        
        % find the corresponding object data index
        nIdx = find([sObject(:).number]==number);
        % find text and show tooltip if there is text
        if ~isempty(nIdx)
            % selected data object
            sObject = sObject(nIdx);
            
            % generate text automatically
            if isappdata(hFigure,'obj')
                swobj = getappdata(hFigure,'obj');
            else
                swobj = [];
            end