When Pressed
Fires when the player presses down on this UI object.
Introduction
When Pressed is an event in the UI group of UI Events. It fires when the player presses down on this UI object. When it fires, the event hands one value to your script: the Current Position of the touch on the UI object. Like every event, it does nothing by itself. It waits for the right moment, then runs all the actions connected to it. Press and release are two halves of one gesture: this event catches the finger touching down, When Released catches it lifting, and When Tapped confirms the complete quick tap. If the player should hold instead, When Pressed for a While measures the hold, and When Touch Move tracks dragging across the panel. Buttons are the most common receiver of this event - see the UI Button guide. When Pressed event in the UI Editor Image The When Pressed event in the UI Editor. caption When Pressed, Fires while the player is holding the UI panel pressed. This event belongs to the "UI" group in UI Events. Trigger: fired by player. Event outputs: Current Position.
Parameters
Current Position where the finger or cursor is on the UI object right now Parameter Description
How to Access
How to Access - When Pressed
Example
When Pressed event with a Play Audio command when-pressed-example.webp Example: the player's progress goes up by one the instant the UI object is pressed. caption
How to Use
Open the UI Editor and press the UI Property button (the document icon in the top toolbar) without selecting any element, the UI Base panel opens on the right. In the panel's Event Triggers section, find When Pressed and press Scripts + next to it, then add the actions that should run when the event fires: what should begin the moment the panel is pressed. Pair it with When Released for complete press and release handling. Press Play and press the panel to confirm the event fires on the press.
Common Uses
Press feedback on custom UI elements Start drag interactions Highlight the pressed object
Tip
Every UI object with a script can listen for When Pressed, not just buttons. Combine it with When Release for complete press handling.