clicked
Callback triggered when the target element is clicked.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Event
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
public event Action clicked
Remarks
The and events are invoked when any of the following conditions occur:
clickedclickedWithEventInfo-
The target receives a NavigationSubmitEvent.
-
The target receives a PointerDownEvent followed by a PointerUpEvent.
If the and optional constructor parameters are used, then the event is considered repeatable and is instead invoked when any of the following conditions occur:
delayintervalclicked-
The target receives a NavigationSubmitEvent.
-
The target just received a PointerDownEvent.
-
The target has received a PointerDownEvent and the pointer button has been held down for a given period of time.
If the event is repeatable, then the first repeated click occurs after an amount of time corresponding to the parameter, and subsequent clicks occur after amounts of time corresponding to the parameter.
clickeddelayintervalThe callback methods registered to this event should have no parameters and return no value.
This manipulator makes use of pointer capture.
Additional Resources: _clickedWithEventInfo, NavigationSubmitEvent, PointerDownEvent, PointerCaptureEvent
Examples
using UnityEngine;using UnityEditor;using UnityEngine.UIElements;public class ButtonExample : EditorWindow{ [MenuItem("Window/Button Example")] public static void ShowExample() { GetWindow<ButtonExample>(); } void CreateGUI() { var button = new Button { text = "Click me" }; button.clicked += OnClick; rootVisualElement.Add(button); } void OnClick() { Debug.Log("Clicked!"); }}