////////////////////////////////////////////////////////////////////////// private void CloseKeyboardOverlay() { Instance = null; // #UAP_Keyboard_Backlog Close keyboard with an animation DestroyImmediate(gameObject); // Announce that the keyboard is now closed UAP_AccessibilityManager.Say(UAP_AccessibilityManager.Localize_Internal("Keyboard_Hidden")); }
public static UAP_VirtualKeyboard ShowOnscreenKeyboard(string prefilledText = "", EKeyboardMode keyboardMode = EKeyboardMode.Default, bool startCapitalized = true, bool alllowMultiline = false) { // Force remove any previously existing keyboard if (Instance != null) { DestroyImmediate(Instance.gameObject); } // Clear any previous listeners ClearAllListeners(); // Instantiate the keyboard var newKeyboard = (Instantiate(Resources.Load(PrefabPath)) as GameObject).GetComponent <UAP_VirtualKeyboard>(); // Initialize with the given parameters newKeyboard.InitializeKeyboard(prefilledText, keyboardMode, startCapitalized, alllowMultiline); Instance = newKeyboard; return(newKeyboard); }
////////////////////////////////////////////////////////////////////////// protected override void OnInteract() { // Determine whether to use custom virtual keyboard or not - use virtual keyboard only on supported platforms and languages, and respect global setting bool useBuiltinVirtualKeyboard = UAP_AccessibilityManager.ShouldUseBuiltInKeyboard(); bool isPassword = IsPassword(); bool isMultiline = false; // Unity UI InputField inputField = GetInputField(); if (inputField != null) { prevText = inputField.text; deltaText = prevText; // Give the Text Field the focus (to bring up the keyboard entry) if (!useBuiltinVirtualKeyboard) { inputField.onValueChanged.AddListener(delegate { ValueChangeCheck(); }); EventSystem.current.SetSelectedGameObject(inputField.gameObject); } else { isMultiline = inputField.multiLine; } } #if ACCESS_NGUI UIInput element = GetNGUIInputField(); if (element != null) { //Debug.Log("Enabling NGUI Input field"); if (!useBuiltinVirtualKeyboard) { if (m_Callback == null) { m_Callback = new EventDelegate(this, "ValueChangeCheck"); } element.onChange.Add(m_Callback); element.isSelected = true; } isMultiline = element.onReturnKey == UIInput.OnReturnKey.NewLine; #pragma warning disable CS0618 // Disabling warning for backwards compatibility. // In newer NGUI versions, 'text' is being obsoleted // and replaced by 'value'. // If the following code line does not compile, // please replace it with the code one line below prevText = element.text; //prevText = element.value; #pragma warning restore deltaText = prevText; } #endif if (useBuiltinVirtualKeyboard) { UAP_VirtualKeyboard.ShowOnscreenKeyboard(prevText, isPassword ? UAP_VirtualKeyboard.EKeyboardMode.Password : UAP_VirtualKeyboard.EKeyboardMode.Default, !isPassword, isMultiline); UAP_VirtualKeyboard.SetOnFinishListener(OnInputFinished); } #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR else { TouchScreenKeyboard.Open(prevText); } #endif }
////////////////////////////////////////////////////////////////////////// private void OnDestroy() { Instance = null; }