返回介绍

TouchScreenKeyboard.Open 打开

发布于 2019-12-18 15:38:40 字数 7661 浏览 1260 评论 0 收藏 0

JavaScript => public static function Open(text: string, keyboardType: TouchScreenKeyboardType = TouchScreenKeyboardType.Default, autocorrection: bool = true, multiline: bool = false, secure: bool = false, alert: bool = false, textPlaceholder: string = “”): TouchScreenKeyboard;
C# => public static TouchScreenKeyboard Open(string text, TouchScreenKeyboardTypekeyboardType = TouchScreenKeyboardType.Default, bool autocorrection = true, bool multiline = false, bool secure = false, bool alert = false, string textPlaceholder = “”);

Parameters 参数

textText to edit.
keyboardTypeType of keyboard (eg, any text, numbers only, etc).
autocorrectionIs autocorrection applied?
multilineCan more than one line of text be entered?
secureIs the text masked (for passwords, etc)?
alertIs the keyboard opened in alert mode?
textPlaceholderText to be used if no other text is present.

Description 描述

Opens the native keyboard provided by OS on the screen.

打开操作系统提供的本地键盘。

The autocorrection determines whether the input tracks unknown words and suggests a more suitable replacement candidate to the user, replacing the typed text automatically unless the user explicitly overrides the action. The multiline determines if user can input more than one line of text. The secure identifies whether the keyboard is used for password. Text in the input field will be hidden from the user except the recently typed character. The keyboard can be opened in the alert mode too. The placeholder string will be displayed when there is no other text in the input field of the keyboard.

自动校准决定是否输入跟踪未知单词,并建议用户更适合的替代单词,自动替换键入的文本,除非用户进行重写行为。multiline属性决定了用户可以输入多于一行的文本。安全标志为是否使用键盘密码。除了最近用户输入的字符在文本输入区域内的字符将会被隐藏。也可以在警报模式中打开键盘。没有任何其他文字在键盘的输入字段中时,将显示占位符字符串。

JavaScript:

#pragma strict
public var stringToEdit: String = "Hello World";
private var keyboard: TouchScreenKeyboard;
// Opens native keyboard
function OnGUI() {
	stringToEdit = GUI.TextField(new Rect(10, 10, 200, 30), stringToEdit, 30);
	if (GUI.Button(new Rect(10, 50, 200, 100), "Default")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
	}
	if (GUI.Button(new Rect(10, 150, 200, 100), "ASCIICapable")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.ASCIICapable);
	}
	if (GUI.Button(new Rect(10, 250, 200, 100), "Numbers and Punctuation")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumbersAndPunctuation);
	}
	if (GUI.Button(new Rect(10, 350, 200, 100), "URL")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.URL);
	}
	if (GUI.Button(new Rect(10, 450, 200, 100), "NumberPad")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumberPad);
	}
	if (GUI.Button(new Rect(10, 550, 200, 100), "PhonePad")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.PhonePad);
	}
	if (GUI.Button(new Rect(10, 650, 200, 100), "NamePhonePad")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NamePhonePad);
	}
	if (GUI.Button(new Rect(10, 750, 200, 100), "EmailAddress")) {
		keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.EmailAddress);
	}
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public string stringToEdit = "Hello World";
    private TouchScreenKeyboard keyboard;
 
    // Opens native keyboard
    void OnGUI() {
        stringToEdit = GUI.TextField(new Rect(10, 10, 200, 30), stringToEdit, 30);
 
        if(GUI.Button (new Rect(10, 50, 200, 100), "Default"))
        {
            keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
        }
        if(GUI.Button (new Rect(10, 150, 200, 100), "ASCIICapable"))
        {
            keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.ASCIICapable);
        }
        if(GUI.Button (new Rect(10, 250, 200, 100), "Numbers and Punctuation"))
        {
            keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumbersAndPunctuation);
        }
        if(GUI.Button (new Rect(10, 350, 200, 100), "URL"))
        {
            keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.URL);    
        }
        if(GUI.Button (new Rect(10, 450, 200, 100), "NumberPad"))
        {
            keyboard = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumberPad);
        }
        if(GUI.Button (new Rect(10, 550, 200, 100), "PhonePad"))
        {
            keyboard = TouchScreenKeyboard.Open ("", TouchScreenKeyboardType.PhonePad);
        }
        if(GUI.Button (new Rect(10, 650, 200, 100), "NamePhonePad"))
        {
            keyboard = TouchScreenKeyboard.Open ("", TouchScreenKeyboardType.NamePhonePad);
        }
        if(GUI.Button (new Rect(10, 750, 200, 100), "EmailAddress"))
        {
            keyboard = TouchScreenKeyboard.Open ("", TouchScreenKeyboardType.EmailAddress);
        }
 
    }
}

touchscreenkeyboard

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文