/// <summary>
 /// LateUpdate.
 /// </summary>
 protected virtual void LateUpdate()
 {
     if (FixCaretPosition != -1)
     {
                         #if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER
         InputFieldProxy.caretPosition = FixCaretPosition;
                         #else
         InputFieldProxy.MoveToEnd();
                         #endif
         FixCaretPosition = -1;
     }
 }
예제 #2
0
 /// <summary>
 /// LateUpdate.
 /// </summary>
 protected virtual void LateUpdate()
 {
     if (FixCaretPosition != -1)
     {
                         #if UNITY_4_6 || UNITY_4_7 || UNITY_5_0
         InputFieldProxy.MoveToEnd();
                         #else
         InputFieldProxy.caretPosition = FixCaretPosition;
                         #endif
         FixCaretPosition = -1;
     }
 }
        /// <summary>
        /// Submits the result.
        /// </summary>
        /// <param name="eventData">Event data.</param>
        /// <param name="isEnter">Is Enter pressed?</param>
        protected virtual void SubmitResult(BaseEventData eventData, bool isEnter)
        {
            if (DisplayListView.SelectedIndex == -1)
            {
                return;
            }

            if (InputFieldProxy.IsMultiLineNewline())
            {
                if (!DisplayListView.gameObject.activeInHierarchy)
                {
                    return;
                }
                else
                {
                    isEnter = false;
                }
            }

            var item = DisplayListView.DataSource[DisplayListView.SelectedIndex];

            if (TargetListView != null)
            {
                TargetListView.Init();
                TargetListView.Set(item, AllowDuplicate);
            }

            var value = GetStringValue(item);

            if (Result == AutocompleteResult.Append)
            {
                int end_position   = (DisplayListView.gameObject.activeInHierarchy && eventData != null && !isEnter) ? InputFieldProxy.caretPosition : CaretPosition;
                var text           = InputFieldProxy.text.Substring(0, end_position);
                var start_position = text.LastIndexOfAny(DelimiterChars) + 1;

                InputFieldProxy.text = InputFieldProxy.text.Substring(0, start_position) + value + InputFieldProxy.text.Substring(end_position);

                InputFieldProxy.caretPosition = start_position + value.Length;
                                #if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER
                // InputField.selectionFocusPosition = start_position + value.Length;
                                #else
                InputFieldProxy.MoveToEnd();
                                #endif
                if (isEnter)
                {
                    FixCaretPosition = start_position + value.Length;
                    InputFieldProxy.ActivateInputField();
                }
            }
            else
            {
                InputFieldProxy.text = value;
                                #if UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER
                InputFieldProxy.caretPosition = value.Length;
                                #else
                InputFieldProxy.ActivateInputField();
                                #endif
                FixCaretPosition = value.Length;
            }

            OnOptionSelected.Invoke();
            OnOptionSelectedItem.Invoke(item);

            HideOptions();
        }