mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Add a LineEdit
/ TextEdit
property to control whether the virtual keyboard should show on focus
This commit is contained in:
parent
1cf573f44d
commit
f29feac7a5
6 changed files with 50 additions and 5 deletions
|
@ -380,7 +380,10 @@
|
|||
Base text writing direction.
|
||||
</member>
|
||||
<member name="virtual_keyboard_enabled" type="bool" setter="set_virtual_keyboard_enabled" getter="is_virtual_keyboard_enabled" default="true">
|
||||
If [code]true[/code], the native virtual keyboard is shown when focused on platforms that support it.
|
||||
If [code]true[/code], the native virtual keyboard is enabled on platforms that support it.
|
||||
</member>
|
||||
<member name="virtual_keyboard_show_on_focus" type="bool" setter="set_virtual_keyboard_show_on_focus" getter="get_virtual_keyboard_show_on_focus" default="true">
|
||||
If [code]true[/code], the native virtual keyboard is shown on focus events on platforms that support it.
|
||||
</member>
|
||||
<member name="virtual_keyboard_type" type="int" setter="set_virtual_keyboard_type" getter="get_virtual_keyboard_type" enum="LineEdit.VirtualKeyboardType" default="0">
|
||||
Specifies the type of virtual keyboard to show.
|
||||
|
|
|
@ -1421,7 +1421,10 @@
|
|||
If [code]false[/code], using [kbd]Ctrl + Left[/kbd] or [kbd]Ctrl + Right[/kbd] ([kbd]Cmd + Left[/kbd] or [kbd]Cmd + Right[/kbd] on macOS) bindings will stop moving caret only if a space or punctuation is detected. If [code]true[/code], it will also stop the caret if a character is part of [code]!"#$%&'()*+,-./:;<=>?@[\]^`{|}~[/code], the Unicode General Punctuation table, or the Unicode CJK Punctuation table. Useful for subword moving. This behavior also will be applied to the behavior of text selection.
|
||||
</member>
|
||||
<member name="virtual_keyboard_enabled" type="bool" setter="set_virtual_keyboard_enabled" getter="is_virtual_keyboard_enabled" default="true">
|
||||
If [code]true[/code], the native virtual keyboard is shown when focused on platforms that support it.
|
||||
If [code]true[/code], the native virtual keyboard is enabled on platforms that support it.
|
||||
</member>
|
||||
<member name="virtual_keyboard_show_on_focus" type="bool" setter="set_virtual_keyboard_show_on_focus" getter="get_virtual_keyboard_show_on_focus" default="true">
|
||||
If [code]true[/code], the native virtual keyboard is shown on focus events on platforms that support it.
|
||||
</member>
|
||||
<member name="wrap_mode" type="int" setter="set_line_wrapping_mode" getter="get_line_wrapping_mode" enum="TextEdit.LineWrappingMode" default="0">
|
||||
Sets the line wrapping mode to use.
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
#endif
|
||||
|
||||
void LineEdit::edit() {
|
||||
_edit(true);
|
||||
}
|
||||
|
||||
void LineEdit::_edit(bool p_show_virtual_keyboard) {
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
}
|
||||
|
@ -70,7 +74,9 @@ void LineEdit::edit() {
|
|||
editing = true;
|
||||
_validate_caret_can_draw();
|
||||
|
||||
if (p_show_virtual_keyboard) {
|
||||
show_virtual_keyboard();
|
||||
}
|
||||
queue_redraw();
|
||||
}
|
||||
|
||||
|
@ -1579,7 +1585,7 @@ void LineEdit::_notification(int p_what) {
|
|||
case NOTIFICATION_FOCUS_ENTER: {
|
||||
// Only allow editing if the LineEdit is not focused with arrow keys.
|
||||
if (!(Input::get_singleton()->is_action_pressed("ui_up") || Input::get_singleton()->is_action_pressed("ui_down") || Input::get_singleton()->is_action_pressed("ui_left") || Input::get_singleton()->is_action_pressed("ui_right"))) {
|
||||
edit();
|
||||
_edit(virtual_keyboard_show_on_focus);
|
||||
emit_signal(SNAME("editing_toggled"), true);
|
||||
}
|
||||
} break;
|
||||
|
@ -2720,6 +2726,14 @@ bool LineEdit::is_virtual_keyboard_enabled() const {
|
|||
return virtual_keyboard_enabled;
|
||||
}
|
||||
|
||||
void LineEdit::set_virtual_keyboard_show_on_focus(bool p_show_on_focus) {
|
||||
virtual_keyboard_show_on_focus = p_show_on_focus;
|
||||
}
|
||||
|
||||
bool LineEdit::get_virtual_keyboard_show_on_focus() const {
|
||||
return virtual_keyboard_show_on_focus;
|
||||
}
|
||||
|
||||
void LineEdit::set_virtual_keyboard_type(VirtualKeyboardType p_type) {
|
||||
virtual_keyboard_type = p_type;
|
||||
}
|
||||
|
@ -3160,6 +3174,8 @@ void LineEdit::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("is_backspace_deletes_composite_character_enabled"), &LineEdit::is_backspace_deletes_composite_character_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_virtual_keyboard_enabled", "enable"), &LineEdit::set_virtual_keyboard_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_virtual_keyboard_enabled"), &LineEdit::is_virtual_keyboard_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_virtual_keyboard_show_on_focus", "show_on_focus"), &LineEdit::set_virtual_keyboard_show_on_focus);
|
||||
ClassDB::bind_method(D_METHOD("get_virtual_keyboard_show_on_focus"), &LineEdit::get_virtual_keyboard_show_on_focus);
|
||||
ClassDB::bind_method(D_METHOD("set_virtual_keyboard_type", "type"), &LineEdit::set_virtual_keyboard_type);
|
||||
ClassDB::bind_method(D_METHOD("get_virtual_keyboard_type"), &LineEdit::get_virtual_keyboard_type);
|
||||
ClassDB::bind_method(D_METHOD("set_clear_button_enabled", "enable"), &LineEdit::set_clear_button_enabled);
|
||||
|
@ -3239,6 +3255,7 @@ void LineEdit::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emoji_menu_enabled"), "set_emoji_menu_enabled", "is_emoji_menu_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "backspace_deletes_composite_character_enabled"), "set_backspace_deletes_composite_character_enabled", "is_backspace_deletes_composite_character_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_enabled"), "set_virtual_keyboard_enabled", "is_virtual_keyboard_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_show_on_focus"), "set_virtual_keyboard_show_on_focus", "get_virtual_keyboard_show_on_focus");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "virtual_keyboard_type", PROPERTY_HINT_ENUM, "Default,Multiline,Number,Decimal,Phone,Email,Password,URL"), "set_virtual_keyboard_type", "get_virtual_keyboard_type");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clear_button_enabled"), "set_clear_button_enabled", "is_clear_button_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_keys_enabled"), "set_shortcut_keys_enabled", "is_shortcut_keys_enabled");
|
||||
|
|
|
@ -148,6 +148,7 @@ private:
|
|||
bool shortcut_keys_enabled = true;
|
||||
|
||||
bool virtual_keyboard_enabled = true;
|
||||
bool virtual_keyboard_show_on_focus = true;
|
||||
VirtualKeyboardType virtual_keyboard_type = KEYBOARD_TYPE_DEFAULT;
|
||||
|
||||
bool middle_mouse_paste_enabled = true;
|
||||
|
@ -262,6 +263,8 @@ private:
|
|||
void _delete(bool p_word = false, bool p_all_to_right = false);
|
||||
void _texture_changed();
|
||||
|
||||
void _edit(bool p_show_virtual_keyboard = true);
|
||||
|
||||
protected:
|
||||
bool _is_over_clear_button(const Point2 &p_pos) const;
|
||||
|
||||
|
@ -401,6 +404,9 @@ public:
|
|||
void set_virtual_keyboard_enabled(bool p_enable);
|
||||
bool is_virtual_keyboard_enabled() const;
|
||||
|
||||
void set_virtual_keyboard_show_on_focus(bool p_show_on_focus);
|
||||
bool get_virtual_keyboard_show_on_focus() const;
|
||||
|
||||
void set_virtual_keyboard_type(VirtualKeyboardType p_type);
|
||||
VirtualKeyboardType get_virtual_keyboard_type() const;
|
||||
|
||||
|
|
|
@ -1849,7 +1849,7 @@ void TextEdit::_notification(int p_what) {
|
|||
draw_caret = true;
|
||||
}
|
||||
|
||||
if (editable) {
|
||||
if (editable && virtual_keyboard_show_on_focus) {
|
||||
_show_virtual_keyboard();
|
||||
}
|
||||
} break;
|
||||
|
@ -3756,6 +3756,14 @@ bool TextEdit::is_virtual_keyboard_enabled() const {
|
|||
return virtual_keyboard_enabled;
|
||||
}
|
||||
|
||||
void TextEdit::set_virtual_keyboard_show_on_focus(bool p_show_on_focus) {
|
||||
virtual_keyboard_show_on_focus = p_show_on_focus;
|
||||
}
|
||||
|
||||
bool TextEdit::get_virtual_keyboard_show_on_focus() const {
|
||||
return virtual_keyboard_show_on_focus;
|
||||
}
|
||||
|
||||
void TextEdit::set_middle_mouse_paste_enabled(bool p_enabled) {
|
||||
middle_mouse_paste_enabled = p_enabled;
|
||||
}
|
||||
|
@ -7003,6 +7011,9 @@ void TextEdit::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_virtual_keyboard_enabled", "enabled"), &TextEdit::set_virtual_keyboard_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_virtual_keyboard_enabled"), &TextEdit::is_virtual_keyboard_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_virtual_keyboard_show_on_focus", "show_on_focus"), &TextEdit::set_virtual_keyboard_show_on_focus);
|
||||
ClassDB::bind_method(D_METHOD("get_virtual_keyboard_show_on_focus"), &TextEdit::get_virtual_keyboard_show_on_focus);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_middle_mouse_paste_enabled", "enabled"), &TextEdit::set_middle_mouse_paste_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_middle_mouse_paste_enabled"), &TextEdit::is_middle_mouse_paste_enabled);
|
||||
|
||||
|
@ -7407,6 +7418,7 @@ void TextEdit::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deselect_on_focus_loss_enabled"), "set_deselect_on_focus_loss_enabled", "is_deselect_on_focus_loss_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_and_drop_selection_enabled"), "set_drag_and_drop_selection_enabled", "is_drag_and_drop_selection_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_enabled"), "set_virtual_keyboard_enabled", "is_virtual_keyboard_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_show_on_focus"), "set_virtual_keyboard_show_on_focus", "get_virtual_keyboard_show_on_focus");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "middle_mouse_paste_enabled"), "set_middle_mouse_paste_enabled", "is_middle_mouse_paste_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "empty_selection_clipboard_enabled"), "set_empty_selection_clipboard_enabled", "is_empty_selection_clipboard_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "wrap_mode", PROPERTY_HINT_ENUM, "None,Boundary"), "set_line_wrapping_mode", "get_line_wrapping_mode");
|
||||
|
|
|
@ -343,6 +343,7 @@ private:
|
|||
bool backspace_deletes_composite_character_enabled = false;
|
||||
bool shortcut_keys_enabled = true;
|
||||
bool virtual_keyboard_enabled = true;
|
||||
bool virtual_keyboard_show_on_focus = true;
|
||||
bool middle_mouse_paste_enabled = true;
|
||||
bool empty_selection_clipboard_enabled = true;
|
||||
|
||||
|
@ -823,6 +824,9 @@ public:
|
|||
void set_virtual_keyboard_enabled(bool p_enabled);
|
||||
bool is_virtual_keyboard_enabled() const;
|
||||
|
||||
void set_virtual_keyboard_show_on_focus(bool p_show_on_focus);
|
||||
bool get_virtual_keyboard_show_on_focus() const;
|
||||
|
||||
void set_middle_mouse_paste_enabled(bool p_enabled);
|
||||
bool is_middle_mouse_paste_enabled() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue