/// <summary> /// Init the input. /// </summary> protected override void InitInput() { if (InputHex != null) { InputProxyHex = new InputFieldProxy(InputHex); } }
/// <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; } }
/// <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> /// Init the input. /// </summary> protected override void InitInput() { if (InputHours != null) { InputProxyHours = new InputFieldProxy(InputHours); } if (InputMinutes != null) { InputProxyMinutes = new InputFieldProxy(InputMinutes); } if (InputSeconds != null) { InputProxySeconds = new InputFieldProxy(InputSeconds); } }
/// <summary> /// This function is called when the MonoBehaviour will be destroyed. /// </summary> protected virtual void OnDestroy() { if (DisplayListView != null) { DisplayListView.OnSelect.RemoveListener(ItemSelected); } if (!InputFieldProxy.IsNull()) { InputFieldProxy.onValueChanged.RemoveListener(ApplyFilter); var inputListener = InputFieldProxy.gameObject.GetComponent <InputFieldListener>(); if (inputListener != null) { inputListener.OnMoveEvent.RemoveListener(SelectResult); inputListener.OnSubmitEvent.RemoveListener(SubmitResult); inputListener.onDeselect.RemoveListener(InputDeselected); } } }
/// <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(); }
/// <summary> /// Show all options. /// </summary> public void ShowAllOptions() { InputFieldProxy.Focus(); ApplyFilter(string.Empty, false); }