keyboard_virtual_show

此函数可用于在运行游戏的设备上显示虚拟键盘。调用此函数时,需要为前三个参数中的每个参数提供以下常量之一:

虚拟键盘类型常量
键盘类型描述
kbv_type_defaultThe default keyboard type for the current system.
kbv_type_asciiAn ASCII-only keyboard.
kbv_type_urlA normal keyboard optimized for URL entry. Usually features a ".com" or other domain keys, as well as "/" and "." keys.
kbv_type_emailA normal keyboard optimized for e-mail entry. Usually features "@" and "." characters.
kbv_type_numbersA numbers-only keyboard, usually displayed as a number pad.
kbv_type_phoneA phone pad keyboard. Usually numbers-only with the "*" and "#" keys.
kbv_type_phone_nameA keyboard optimized for entering both a phone number and a name. Usually similar to an ASCII keyboard, but with a limited special characters selection.

 

虚拟键盘返回类型常量
返回类型描述
kbv_returnkey_defaultThe default return key title for the current system.
kbv_returnkey_goSets the return key title to "Go".
kbv_returnkey_googleSets the return key title to "Google", or to a generic search icon in some cases.
kbv_returnkey_joinSets the return key title to "Go".
kbv_returnkey_nextSets the return key title to "Next".
kbv_returnkey_routeSets the return key title to "Route".
kbv_returnkey_searchSets the return key title to "Search", or to a generic search icon in some cases.
kbv_returnkey_sendSets the return key title to "Send".
kbv_returnkey_yahooSets the return key title to "Yahoo", or to a generic search icon in some cases.
kbv_returnkey_doneSets the return key title to "Done".
kbv_returnkey_continueSets the return key title to "Continue".
kbv_returnkey_emergencySets the return key title to "Emergency Call".

 

虚拟键盘自动大写类型常量
自动大写类型描述
kbv_autocapitalize_noneAutocapitalization is disabled.
kbv_autocapitalize_wordsWords will be auto-capitalized.
kbv_autocapitalize_sentencesSentences will be auto-capitalized.
kbv_autocapitalize_charactersAll characters will be capitalized.

 

最后一个参数是启用/禁用预想英文输入法,这将被设置为true以允许它,否则设置为false,但请注意,仅仅因为它被允许并不意味着它将被使用,因为这将取决于用户在设备上的偏好。在预想英文输入法模式下,虚拟键盘不会生成正常的GameMaker按键事件。相反,它将只更新最后一个按下的字符和键盘字符串变量。这是由于无法检测用于检测按键的内部文本字段中的变化是来自实际的虚拟键盘键还是来自文本建议。在这些情况下,您可能希望读取keyboard_string输入,而不是读取任何类型的原始按键输入。

还需要注意的是,根据平台操作系统的不同,用户将获得具有不同函数的不同键盘,每个目标的使用注意事项如下:

无法使用返回键替换键
kbv_returnkey_google
kbv_returnkey_yahoo
kbv_returnkey_search
kbv_returnkey_join
kbv_returnkey_route
kbv_returnkey_emergency
kbv_returnkey_go
kbv_returnkey_continuekbv_returnkey_next

 

调用此函数将生成系统异步事件,其中 async_load DS 映射将填充以下键/值对:

 

语法

keyboard_virtual_show(keyboard_type, return_key_type, autocapitalization_type, predictive_text_enabled);

参数类型描述
keyboard_type虚拟键盘类型常量确定虚拟键盘上的可用键集(请参阅顶部的表)
return_key_type虚拟键盘返回类型常量确定虚拟键盘的返回/操作键上显示的内容(参见顶部的表格)
autocapitalization_type虚拟键盘自动大写类型常量确定如何/是否将通过虚拟键盘键入的单词自动大写(请参阅顶部的表格)
predictive_text_enabledBoolean设置为true/false以启用/禁用预想英文输入法。

 

返回:

N/A

 

例子:

if (input == false)
{
    input = true;
    keyboard_virtual_show(kbv_type_numbers, kbv_returnkey_default, kbv_autocapitalize_none, false);
}

如果给定的变量未设置为true,则上面的代码将调出操作系统虚拟键盘。