当用户与 UI 工具包中的元素交互并更改这些元素的状态时,UI 工具包会发送一个事件。例如,以下操作均已关联:
事件的设计类似于用于 HTML 元素的事件接口。
事件类型适合基于 EventBase 类的层级视图。每个事件系列都实现了一个接口;该接口定义了同一系列的所有事件的共同特征。例如,BlurEvent
和 FocusEvent
使用 FocusEventBase 类。
选择下面列出的任何事件类型,以获取有关事件、其父类和 API 文档链接的更多信息。
下表是每种事件类型的简单概述。有关某个事件的更多信息,请参阅上面列出的页面。
事件类型 | 描述 | 涓滴 | 冒泡 | 可取消 | |
---|---|---|---|---|---|
捕获事件 | |||||
MouseCaptureEvent | 当某一元素接受鼠标捕获时发送。 | 是 | 是 | ||
MouseCaptureOutEvent | 当某一元素释放鼠标捕获或以其他方式失去鼠标捕获时发送。 | 是 | 是 | ||
PointerCaptureEvent | 当某一元素捕获指针时发送。 | 是 | 是 | ||
PointerCaptureOutEvent | 当某一元素释放指针时发送。 | 是 | 是 | ||
更改事件 | |||||
ChangeEvent | 当某个元素的值更改时发送的通用事件。 | 是 | 是 | ||
命令事件 | |||||
ValidateCommandEvent | IMGUI 可确定该命令是否由面板中的某一元素处理时发送此事件。 | 是 | 是 | 是 | |
ExecuteCommandEvent | 当面板中的某一元素应执行命令时,IMGUI 发送此事件。 | 是 | 是 | 是 | |
拖动事件 | |||||
DragExitedEvent | 在拖放过程结束时发送。 | 是 | 是 | ||
DragUpdatedEvent | 在拖动的元素移到放置目标上方时发送。 | 是 | 是 | 是 | |
DragPerformEvent | 在拖动的元素放置到可接收目标上方时发送。 | 是 | 是 | 是 | |
DragEnterEvent | 拖动的元素进入了新的 VisualElement 。此事件在拖动操作开始时发送。 |
是 | |||
DragLeaveEvent | 拖动的元素离开了当前放置目标。此事件在拖动操作结束时发送。 | 是 | |||
焦点事件 | |||||
FocusOutEvent | 某一元素失去焦点前发送。 | 是 | 是 | ||
FocusInEvent | 某一元素获得焦点前发送。 | 是 | 是 | ||
BlurEvent | 某一元素失去焦点后发送。 | 是 | |||
FocusEvent | 某一元素获得焦点后发送。 | 是 | |||
IMGUI 事件 | |||||
IMGUIEvent | 发送以封装 IMGUI 特定事件。 | 是 | 是 | 是 | |
输入事件 | |||||
InputEvent | 在数据输入到视觉元素(通常是控件)时发送。 | ||||
键盘事件 | |||||
KeyDownEvent | 用户按下键盘上的某个键时发送。 | 是 | 是 | 是 | |
KeyUpEvent | 用户松开键盘上的某个键时发送。 | 是 | 是 | 是 | |
布局事件 | |||||
GeometryChangedEvent | 当某一元素的位置或尺寸发生变化时发送。 | ||||
鼠标事件 | |||||
MouseDownEvent | 当用户按下鼠标键时发送。 | 是 | 是 | 是 | |
MouseUpEvent | 当用户释放鼠标键时发送。 | 是 | 是 | 是 | |
MouseMoveEvent | 当用户移动鼠标时发送。 | 是 | 是 | 是 | |
WheelEvent | 当用户激活鼠标滚轮时发送。 | 是 | 是 | 是 | |
MouseEnterWindowEvent | 当鼠标进入某个窗口时发送。 | Yes | |||
MouseLeaveWindowEvent | 当鼠标离开某个窗口时发送。 | Yes | |||
MouseEnterEvent | 当鼠标进入某一元素或其后代之一时发送。 | 是 | 是 | ||
MouseLeaveEvent | 当鼠标离开某一元素或其后代之一时发送。 | 是 | 是 | ||
MouseOverEvent | 当鼠标进入某一元素时发送。 | 是 | 是 | 是 | |
MouseOutEvent | 当鼠标离开某一元素时发送。 | 是 | 是 | 是 | |
ContextClickEvent(已弃用) | 用户按下并松开第三个鼠标键时发送。此事件用于向后兼容 IMGUI。 | 是 | 是 | 是 | |
指针事件 | |||||
PointerDownEvent | 当您按下指针时发送。 | 是 | 是 | 是 | |
PointerUpEvent | 当您松开指针时发送。 | 是 | 是 | 是 | |
PointerMoveEvent | 当指针状态变化时发送。 | 是 | 是 | 是 | |
PointerEnterEvent | 当指针进入某一视觉元素或其后代之一时发送。 | 是 | 是 | ||
PointerLeaveEvent | 当指针离开某一视觉元素及其所有后代时发送。 | 是 | 是 | ||
PointerOverEvent | 当指针进入某一视觉元素时发送。 | 是 | 是 | 是 | |
PointerOutEvent | 当指针离开某一视觉元素时发送。 | 是 | 是 | 是 | |
PointerStationaryEvent | 当某个指针类型(如触笔或手指)经过操作系统设定的时间量之后未发生变化时发送。 | 是 | 是 | 是 | |
PointerCancelEvent | 当操作系统取消指针操作时发送。 | 是 | 是 | 是 | |
面板事件 | |||||
AttachToPanelEvent | 在元素附加到某个面板后立即发送。 | ||||
DetachFromPanelEvent | 在元素即将从某个面板分离时发送。 | ||||
工具提示事件 | |||||
TooltipEvent | 在即将显示某个工具提示时发送。 | 是 | 是 | 是 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.