Пример #1
0
        public void Show(FileSelectionViewControllerDelegate Delegate)
        {
            this.controllerDelegate = Delegate;

            this.containerRect = itemTemplate.transform.parent.GetComponent <RectTransform>();

            InputRegistry.shared.Register(InputType.All, this, EventHandleMode.ConsumeEvent);
            GestureRecognizerCollection.shared.GetAndroidBackButtonGestureRecognizer().OnGesture += OnAndroidBackButton;

            DeleteAllItemViews();
            gameObject.SetActive(true);
            RefreshSearch();
            searchInputField.text = "";
            searchInputField.onValueChanged.AddListener(delegate(string value) {
                this.searchResult = this.search.Find(value);
                Refresh();
            });

            Refresh();
            ScrollSelectedItemToTop();

                        #if !UNITY_IOS && !UNITY_ANDROID
            searchInputField.Select();
                        #endif
        }
Пример #2
0
 public void TMProSelectAllText()
 {
     inputField.Select();
     if (inputField.text.Length > 0)
     {
         inputField.caretPosition           = inputField.text.Length;
         inputField.selectionAnchorPosition = 0;
         inputField.selectionFocusPosition  = inputField.text.Length;
     }
 }
Пример #3
0
 public void Update()
 {
     if (Input.GetKeyDown(KeyCode.Tab) && userName.isFocused)
     {
         password.Select();
     }
     else if ((Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) && Input.GetKeyDown(KeyCode.Tab) && password.isFocused)
     {
         userName.Select();
     }
 }
Пример #4
0
        public IEnumerator TestOnClickEvent()
        {
            yield return(InputTextCreate());

            //------------------------------------------------------------------------
            // Test click events
            TMPro.TMP_InputField inputField = textInput.referencesContainer.inputField;

            string targetEventType = "SceneEvent";

            var onClickEvent = new WebInterface.OnClickEvent();

            onClickEvent.uuid = textInput.model.onClick;

            var sceneEvent = new WebInterface.SceneEvent <WebInterface.OnClickEvent>();

            sceneEvent.sceneId   = scene.sceneData.id;
            sceneEvent.payload   = onClickEvent;
            sceneEvent.eventType = "uuidEvent";
            string eventJSON = JsonUtility.ToJson(sceneEvent);

            bool eventTriggered = false;


            yield return(TestHelpers.WaitForMessageFromEngine(targetEventType, eventJSON,
                                                              () =>
            {
                UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(inputField.gameObject, null);
                inputField.ActivateInputField();
                inputField.Select();
            },
                                                              () =>
            {
                eventTriggered = true;
            }));

            yield return(null);

            Assert.IsTrue(eventTriggered);
        }
        /// <summary>
        /// Targets the indicated input field for the keyboard. This will also 'select' the InputField in Unity UI
        /// </summary>
        /// <param name="target"></param>
        public void SetInputTarget(TMPro.TMP_InputField target)
        {
            if (!ValidateHost())
            {
                return;
            }

            _tmpInputField = target;
            _inputField    = null;

            if (_tmpInputField != null)
            {
                _tmpInputField.Select();
                LastTMProInputField = _tmpInputField;
                if (_tmpInputField.selectionAnchorPosition > _tmpInputField.selectionFocusPosition)
                {
                    insertPoint     = _tmpInputField.selectionFocusPosition;
                    selectionLength = _tmpInputField.selectionAnchorPosition - _tmpInputField.selectionFocusPosition;
                }
                else if (_tmpInputField.selectionFocusPosition > _tmpInputField.selectionAnchorPosition)
                {
                    insertPoint     = _tmpInputField.selectionAnchorPosition;
                    selectionLength = _tmpInputField.selectionFocusPosition - _tmpInputField.selectionAnchorPosition;
                }
                else
                {
                    insertPoint     = _tmpInputField.selectionAnchorPosition;
                    selectionLength = 0;
                }
            }

            if (_tmpInputField != null && EventSystem.current.currentSelectedGameObject != linkedGameObject)
            {
                LastTMProInputField = _tmpInputField;
                linkedGameObject    = EventSystem.current.currentSelectedGameObject;
                linkedBehaviour     = LastTMProInputField;
                field = "text";
            }
        }