需要使用UIShowCustomLayoutParametersTooltipEvent和UIHideCustomLayoutTooltipEvent

这里有详细的Events

我为其封装了这样的工具函数

//显示自定义Tooltip,这里参数似乎有255长度限制,需要注意
static ShowCustomTooltip(target:Panel, id:string, tooltipPath:string, argMap?:Map<string,string>)
{
    let strArg:string = null;

    if (argMap !== undefined && argMap.size > 0)
    {
        strArg = "";
        for (let arg of argMap)
        {
            strArg += `${arg[0]}=${arg[1]}&`
        }

        strArg = strArg.substr(0, strArg.length-1);  
        if (strArg.length > 255)
        {
            $.Warning(`ShowCustomTooltip 参数长度超255,可能会出问题`)
        }
    }

    $.DispatchEvent("UIShowCustomLayoutParametersTooltip", target,id, tooltipPath, strArg)
}
        
//关闭指定id的自定义Tooltip
static HideCustomTooltip(target:Panel,id:string)
{
    if (target === undefined)
        return;

    $.DispatchEvent("UIHideCustomLayoutTooltip", target, id);
}

使用地方

const arg = new Map<string,string>();
        
arg.set("path", path);

ShowCustomTooltip(panel, "IcMovieTooltip", "file://{resources}/layout/custom_game/Tooltip/Movie/MoviePlay.xml", arg)

HideCustomTooltip(this._lastItem,"IcMovieTooltip");

xml中需要添加ontooltiploaded,也可以直接通过SetPanelEvent("ontooltiploaded",()=>{})设置

<Panel class="Root" hittest="false" ontooltiploaded="setupTooltip()">
    <Movie id="Control" hittest="false"/>
</Panel>

xml的ts脚本

let movie:MoviePanel = null;

function setupTooltip()
{
    const path = $.GetContextPanel().GetAttributeString("path", null);
    
    if (path === null)
    {
        movie.Stop();
        
        return;
    }

    if (movie === null)
        movie = $("#Control") as MoviePanel;
    
    movie.SetMovie(path);
    movie.Play();
}

这样一个自定义的Tooltip就完成了