UI Toolbox 徽标UI Toolbox
支持

本页为译文。技术支持和视频教程主要使用英语,内容以英文页面为准。 英文版

工具提示

只有 Editor 面板会显示元素的 tooltip 文本。在运行时面板中,由工作区来显示它:

带有粗体 Fireball 标题、伤害与冷却富文本以及指向 Fireball 按钮箭头的 ToolTip带有粗体 Fireball 标题、伤害与冷却富文本以及指向 Fireball 按钮箭头的 ToolTip

<ui:Button
    text="Save"
    tooltip="Saves the layout. &lt;b&gt;Ctrl+S&lt;/b&gt;" />

ToolTip

ToolTip 增加了标题、自己的延迟,以及带箭头位于目标旁边的位置:

<ui:Button name="target-button" text="Save" />
<tb:ToolTip
    target="target-button"
    title="Save"
    description="Saves the layout. &lt;b&gt;Ctrl+S&lt;/b&gt;"
    show-delay="300"
    placement="Below" />
var tip = new ToolTip
{
    Title = "Save",
    Description = "Saves the layout.",
    Placement = TooltipPlacement.Right
};
tip.AttachTo(saveButton);
属性(Attribute) 属性(Property) 默认值 说明
target TargetName 空 目标的名称。元素附加到面板时,先在其父级下查找,然后依次在每个祖先下查找。
title Title 空 粗体的第一行。空表示不显示标题。
description Description 空 富文本。元素把它放进目标的 tooltip,所以 Editor 面板仍然会显示它。
show-delay ShowDelayMs -1 工具提示显示之前的毫秒数。负值使用工作区的 tooltip-delay。
hide-delay HideDelayMs 0 指针离开目标后工具提示保留的毫秒数。如果指针在这段时间内回来,工具提示保持。下一个工具提示会等待这次隐藏。0 表示立即隐藏。
placement Placement Pointer Pointer 把它显示在指针附近,没有箭头。Below、Above、Right 和 Left 把它居中放在目标的那一侧,箭头指向目标中心。该侧没有空间时,它会翻转到另一侧。
tooltip-class TooltipClass 空 工具提示为该目标显示期间所带的 USS 类,类之间用空格分隔。参见颜色和你自己的外观。

颜色和你自己的外观

工作区为所有目标只有一个工具提示。tooltip-class 只为一个目标在其上添加类:

<tb:ToolTip
    target="delete-button"
    title="Delete"
    description="You cannot undo this."
    placement="Below"
    tooltip-class="tb-tooltip--error" />
类 常量 颜色
tb-tooltip--accent ToolTip.ACCENT_CLASS --tb-color-accent 配 --tb-color-accent-text
tb-tooltip--success ToolTip.SUCCESS_CLASS --tb-color-success 配 --tb-color-background
tb-tooltip--warning ToolTip.WARNING_CLASS --tb-color-warning 配 --tb-color-background
tb-tooltip--error ToolTip.ERROR_CLASS --tb-color-danger 配 --tb-color-danger-text

要有你自己的外观,请在样式表中命名一个类。箭头与框使用相同的颜色,文字颜色设在标签上:

.tb-tooltip.my-tooltip,
.tb-tooltip.my-tooltip > .tb-tooltip__arrow {
    background-color: rgb(46, 16, 74);
    border-color: rgb(255, 121, 198);
}
.tb-tooltip.my-tooltip { border-radius: 12px; font-size: 14px; }
.tb-tooltip.my-tooltip > Label { color: rgb(255, 214, 240); }

样式表必须位于工作区上或其上方的元素上,因为工具提示是工作区的子元素。

样式

类 元素
tb-tooltip 工作区的工具提示(绝对定位,最大 320 px 宽,显示之前不透明度为 0)。
tb-tooltip--shown 工具提示显示时添加(不透明度 1)。
tb-tooltip--anim-fade 淡入的过渡类(不透明度,--tb-animation-duration-fast)。
tb-tooltip__header、tb-tooltip__body 粗体标题(为空时隐藏)和富文本。
tb-tooltip__arrow 旋转 45 度的 10 px 方块,带有工具提示的背景。在指针附近隐藏。
tb-tooltip--below、--above、--right、--left 翻转之后目标所在的一侧。每个类把箭头放在相对的边缘,并显示朝外的两条边框。

ToolTipDemo 场景展示了:暂停菜单按钮上的纯文本工具提示、快捷栏中每个技能上方的标题和富文本、工具提示等待指针返回的物品属性、对键盘和游戏手柄自我说明的设置,以及宝箱工具提示的七种外观。