mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 21:52:51 +00:00
Add option to disable virtual keyboard for LineEdit
Co-authored-by: Alexander Holland <alexander.holland@live.de>
This commit is contained in:
parent
f6b6d51052
commit
0aa56e3ab8
@ -167,6 +167,9 @@
|
||||
String value of the [LineEdit].
|
||||
[b]Note:[/b] Changing text using this property won't emit the [signal text_changed] signal.
|
||||
</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.
|
||||
</member>
|
||||
</members>
|
||||
<signals>
|
||||
<signal name="text_change_rejected">
|
||||
|
@ -118,7 +118,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
|
||||
selection.creating = false;
|
||||
selection.doubleclick = false;
|
||||
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) {
|
||||
if (selection.enabled) {
|
||||
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, selection.begin, selection.end);
|
||||
} else {
|
||||
@ -309,7 +309,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
|
||||
case KEY_KP_ENTER:
|
||||
case KEY_ENTER: {
|
||||
emit_signal("text_entered", text);
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) {
|
||||
DisplayServer::get_singleton()->virtual_keyboard_hide();
|
||||
}
|
||||
|
||||
@ -937,7 +937,7 @@ void LineEdit::_notification(int p_what) {
|
||||
DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id());
|
||||
}
|
||||
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) {
|
||||
if (selection.enabled) {
|
||||
DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, selection.begin, selection.end);
|
||||
} else {
|
||||
@ -958,7 +958,7 @@ void LineEdit::_notification(int p_what) {
|
||||
ime_text = "";
|
||||
ime_selection = Point2();
|
||||
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) {
|
||||
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) {
|
||||
DisplayServer::get_singleton()->virtual_keyboard_hide();
|
||||
}
|
||||
|
||||
@ -1658,6 +1658,14 @@ bool LineEdit::is_shortcut_keys_enabled() const {
|
||||
return shortcut_keys_enabled;
|
||||
}
|
||||
|
||||
void LineEdit::set_virtual_keyboard_enabled(bool p_enable) {
|
||||
virtual_keyboard_enabled = p_enable;
|
||||
}
|
||||
|
||||
bool LineEdit::is_virtual_keyboard_enabled() const {
|
||||
return virtual_keyboard_enabled;
|
||||
}
|
||||
|
||||
void LineEdit::set_selecting_enabled(bool p_enabled) {
|
||||
selecting_enabled = p_enabled;
|
||||
|
||||
@ -1813,6 +1821,8 @@ void LineEdit::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_menu"), &LineEdit::get_menu);
|
||||
ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_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_clear_button_enabled", "enable"), &LineEdit::set_clear_button_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_clear_button_enabled"), &LineEdit::is_clear_button_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_shortcut_keys_enabled", "enable"), &LineEdit::set_shortcut_keys_enabled);
|
||||
@ -1848,6 +1858,7 @@ void LineEdit::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "secret_character"), "set_secret_character", "get_secret_character");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand_to_text_length"), "set_expand_to_text_length", "get_expand_to_text_length");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_enabled"), "set_virtual_keyboard_enabled", "is_virtual_keyboard_enabled");
|
||||
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");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled");
|
||||
|
@ -90,6 +90,8 @@ private:
|
||||
|
||||
bool shortcut_keys_enabled;
|
||||
|
||||
bool virtual_keyboard_enabled = true;
|
||||
|
||||
Ref<Texture2D> right_icon;
|
||||
|
||||
struct Selection {
|
||||
@ -227,6 +229,9 @@ public:
|
||||
void set_shortcut_keys_enabled(bool p_enabled);
|
||||
bool is_shortcut_keys_enabled() const;
|
||||
|
||||
void set_virtual_keyboard_enabled(bool p_enable);
|
||||
bool is_virtual_keyboard_enabled() const;
|
||||
|
||||
void set_selecting_enabled(bool p_enabled);
|
||||
bool is_selecting_enabled() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user