allow toggling line edit via action that isn't keyboard

This commit is contained in:
Travis Lange 2026-02-10 10:54:46 -05:00
parent 377b5a3175
commit 1cbad83f83

View file

@ -660,13 +660,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
return;
}
Ref<InputEventKey> k = p_event;
if (k.is_null()) {
return;
}
if (editable && !editing && k->is_action_pressed("ui_text_submit", false)) {
if (editable && !editing && p_event->is_action_pressed("ui_text_submit", false)) {
edit();
emit_signal(SNAME("editing_toggled"), true);
accept_event();
@ -675,7 +669,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
// Open context menu.
if (context_menu_enabled) {
if (k->is_action("ui_menu", true)) {
if (p_event->is_action("ui_menu", true)) {
_update_context_menu();
Point2 pos = Point2(get_caret_pixel_pos().x, (get_size().y + theme_cache.font->get_height(theme_cache.font_size)) / 2);
menu->set_position(get_screen_transform().xform(pos));
@ -689,19 +683,19 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
}
if (is_shortcut_keys_enabled()) {
if (k->is_action("ui_copy", true)) {
if (p_event->is_action("ui_copy", true)) {
copy_text();
accept_event();
return;
}
if (k->is_action("ui_text_select_all", true)) {
if (p_event->is_action("ui_text_select_all", true)) {
select();
accept_event();
return;
}
if (k->is_action("ui_cut", true)) {
if (p_event->is_action("ui_cut", true)) {
if (editable) {
cut_text();
} else {
@ -716,6 +710,12 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) {
return;
}
Ref<InputEventKey> k = p_event;
if (k.is_null()) {
return;
}
// Start Unicode Alt input (hold).
if (k->is_alt_pressed() && k->get_keycode() == Key::KP_ADD && !alt_start && !alt_start_no_hold) {
if (selection.enabled) {