Version: 2019.3
USS Writing style sheets
Dispatching Events

The Event System

UIElements includes an event systemA way of sending events to objects in the application based on input, be it keyboard, mouse, touch, or custom input. The Event System consists of a few components that work together to send events. More info
See in Glossary
that communicates user interactions to visual elements. Inspired by HTML events, the UIElements events system shares many of the same terminology and event naming. The UlElement event system is comprised of the following:

  • Event dispatcher: UIElements listens to events, coming from the operating system or scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
    See in Glossary
    , and dispatches these events with the Event dispatcher. The Event dispatcher also determines the dispatching strategy used to send events to visual elements and other supporting classes.
  • Event handler: When an event occurs inside a panel, the event is sent to the VisualElement tree within the panel. You can add event handlers to visual elements to respond to certain event types when they occur. See Responding to events.
  • Event synthesizer: The operating system is not the only source of events. Scripts can also create and dispatch events through the dispatcher. See Synthesizing Events for more on creating and dispatching events.
  • Event types: The different event types are organized into a hierarchy based on EventBase and grouped into families. Each family of events implements an interface that defines the common characteristics for all events of the same family. For example, MouseUpEvent, MouseDownEvent and other mouse events implement the IMouseEvent inteface. This interface specifies that each mouse event has a position, a pressed button, a set of modifers, and other mouse-related event types. See Event type reference for a description of each event family and their UIElement event types.

You can also use events to communicate other types of messages to visual elements. For example, the ContextualMenuManager uses the ContextualMenuPopulateEvent to add items to a contextual menu. See built-in controls.


  • 2018–11–02 Page amended
USS Writing style sheets
Dispatching Events