Add support for multiple virtual keyboard types
This commit is contained in:
parent
9f408aef45
commit
103c0fa6e6
24 changed files with 259 additions and 42 deletions
|
|
@ -604,8 +604,8 @@ void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_c
|
|||
}
|
||||
}
|
||||
|
||||
void DisplayServerJavaScript::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, bool p_multiline, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
|
||||
godot_js_display_vk_show(p_existing_text.utf8().get_data(), p_multiline, p_cursor_start, p_cursor_end);
|
||||
void DisplayServerJavaScript::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end) {
|
||||
godot_js_display_vk_show(p_existing_text.utf8().get_data(), p_type, p_cursor_start, p_cursor_end);
|
||||
}
|
||||
|
||||
void DisplayServerJavaScript::virtual_keyboard_hide() {
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ public:
|
|||
virtual float screen_get_scale(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
||||
virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
|
||||
|
||||
virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), bool p_multiline = false, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override;
|
||||
virtual void virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2(), VirtualKeyboardType p_type = KEYBOARD_TYPE_DEFAULT, int p_max_input_length = -1, int p_cursor_start = -1, int p_cursor_end = -1) override;
|
||||
virtual void virtual_keyboard_hide() override;
|
||||
|
||||
// windows
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ extern void godot_js_display_notification_cb(void (*p_callback)(int p_notificati
|
|||
extern int godot_js_display_vk_available();
|
||||
extern int godot_js_display_tts_available();
|
||||
extern void godot_js_display_vk_cb(void (*p_input)(const char *p_text, int p_cursor));
|
||||
extern void godot_js_display_vk_show(const char *p_text, int p_multiline, int p_start, int p_end);
|
||||
extern void godot_js_display_vk_show(const char *p_text, int p_type, int p_start, int p_end);
|
||||
extern void godot_js_display_vk_hide();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ const GodotDisplayVK = {
|
|||
GodotDisplayVK.textarea = create('textarea');
|
||||
GodotDisplayVK.updateSize();
|
||||
},
|
||||
show: function (text, multiline, start, end) {
|
||||
show: function (text, type, start, end) {
|
||||
if (!GodotDisplayVK.textinput || !GodotDisplayVK.textarea) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -81,7 +81,46 @@ const GodotDisplayVK = {
|
|||
GodotDisplayVK.hide();
|
||||
}
|
||||
GodotDisplayVK.updateSize();
|
||||
const elem = multiline ? GodotDisplayVK.textarea : GodotDisplayVK.textinput;
|
||||
|
||||
let elem = GodotDisplayVK.textinput;
|
||||
switch (type) {
|
||||
case 0: // KEYBOARD_TYPE_DEFAULT
|
||||
elem.type = 'text';
|
||||
elem.inputmode = '';
|
||||
break;
|
||||
case 1: // KEYBOARD_TYPE_MULTILINE
|
||||
elem = GodotDisplayVK.textarea;
|
||||
break;
|
||||
case 2: // KEYBOARD_TYPE_NUMBER
|
||||
elem.type = 'text';
|
||||
elem.inputmode = 'numeric';
|
||||
break;
|
||||
case 3: // KEYBOARD_TYPE_NUMBER_DECIMAL
|
||||
elem.type = 'text';
|
||||
elem.inputmode = 'decimal';
|
||||
break;
|
||||
case 4: // KEYBOARD_TYPE_PHONE
|
||||
elem.type = 'tel';
|
||||
elem.inputmode = '';
|
||||
break;
|
||||
case 5: // KEYBOARD_TYPE_EMAIL_ADDRESS
|
||||
elem.type = 'email';
|
||||
elem.inputmode = '';
|
||||
break;
|
||||
case 6: // KEYBOARD_TYPE_PASSWORD
|
||||
elem.type = 'password';
|
||||
elem.inputmode = '';
|
||||
break;
|
||||
case 7: // KEYBOARD_TYPE_URL
|
||||
elem.type = 'url';
|
||||
elem.inputmode = '';
|
||||
break;
|
||||
default:
|
||||
elem.type = 'text';
|
||||
elem.inputmode = '';
|
||||
break;
|
||||
}
|
||||
|
||||
elem.readonly = false;
|
||||
elem.disabled = false;
|
||||
elem.value = text;
|
||||
|
|
@ -694,11 +733,11 @@ const GodotDisplay = {
|
|||
* Virtual Keyboard
|
||||
*/
|
||||
godot_js_display_vk_show__sig: 'viiii',
|
||||
godot_js_display_vk_show: function (p_text, p_multiline, p_start, p_end) {
|
||||
godot_js_display_vk_show: function (p_text, p_type, p_start, p_end) {
|
||||
const text = GodotRuntime.parseString(p_text);
|
||||
const start = p_start > 0 ? p_start : 0;
|
||||
const end = p_end > 0 ? p_end : start;
|
||||
GodotDisplayVK.show(text, p_multiline, start, end);
|
||||
GodotDisplayVK.show(text, p_type, start, end);
|
||||
},
|
||||
|
||||
godot_js_display_vk_hide__sig: 'v',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue