// UITK TreeView is not supported in earlier versions // Therefore the UITK version of the InputActionAsset Editor is not available on earlier Editor versions either. #if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS using System; using System.Threading.Tasks; using UnityEditor; using UnityEngine.InputSystem.Editor; using UnityEngine.UIElements; namespace UnityEngine.InputSystem.Editor { /// /// A visual element that supports renaming of items. /// internal class InputActionMapsTreeViewItem : VisualElement { public EventCallback EditTextFinishedCallback; private const string kRenameTextField = "rename-text-field"; public event EventCallback EditTextFinished; public Action OnContextualMenuPopulateEvent; // for testing purposes to know if the item is focused to accept input internal bool IsFocused { get; private set; } = false; private bool m_IsEditing; private static InputActionMapsTreeViewItem s_EditingItem = null; public InputActionMapsTreeViewItem() { var template = AssetDatabase.LoadAssetAtPath( InputActionsEditorConstants.PackagePath + InputActionsEditorConstants.ResourcesPath + InputActionsEditorConstants.InputActionMapsTreeViewItemUxml); template.CloneTree(this); focusable = true; delegatesFocus = false; renameTextfield.selectAllOnFocus = true; renameTextfield.selectAllOnMouseUp = false; RegisterCallback(OnMouseDownEventForRename); renameTextfield.RegisterCallback(e => IsFocused = true); renameTextfield.RegisterCallback(e => { OnEditTextFinished(); IsFocused = false; }); _ = new ContextualMenuManipulator(menuBuilder => { OnContextualMenuPopulateEvent?.Invoke(menuBuilder); }) { target = this }; } public Label label => this.Q