Fixed #15082: line edit emits two "text_changed" signals when pasting while text is selected
(cherry picked from commit 9cd3ed4ace
)
This commit is contained in:
parent
a0e59a7259
commit
069658f1be
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "line_edit.h"
|
#include "line_edit.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
|
#include "message_queue.h"
|
||||||
#include "os/keyboard.h"
|
#include "os/keyboard.h"
|
||||||
#include "os/os.h"
|
#include "os/os.h"
|
||||||
#include "print_string.h"
|
#include "print_string.h"
|
||||||
|
@ -800,7 +801,12 @@ void LineEdit::paste_text() {
|
||||||
if (selection.enabled) selection_delete();
|
if (selection.enabled) selection_delete();
|
||||||
append_at_cursor(paste_buffer);
|
append_at_cursor(paste_buffer);
|
||||||
|
|
||||||
_text_changed();
|
if (!text_changed_dirty) {
|
||||||
|
if (is_inside_tree()) {
|
||||||
|
MessageQueue::get_singleton()->push_call(this, "_text_changed");
|
||||||
|
}
|
||||||
|
text_changed_dirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,7 +980,12 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) {
|
||||||
window_pos = cursor_pos;
|
window_pos = cursor_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
_text_changed();
|
if (!text_changed_dirty) {
|
||||||
|
if (is_inside_tree()) {
|
||||||
|
MessageQueue::get_singleton()->push_call(this, "_text_changed");
|
||||||
|
}
|
||||||
|
text_changed_dirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::set_text(String p_text) {
|
void LineEdit::set_text(String p_text) {
|
||||||
|
@ -1341,6 +1352,7 @@ void LineEdit::_text_changed() {
|
||||||
void LineEdit::_emit_text_change() {
|
void LineEdit::_emit_text_change() {
|
||||||
emit_signal("text_changed", text);
|
emit_signal("text_changed", text);
|
||||||
_change_notify("text");
|
_change_notify("text");
|
||||||
|
text_changed_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::_clear_redo() {
|
void LineEdit::_clear_redo() {
|
||||||
|
@ -1373,6 +1385,7 @@ void LineEdit::_create_undo_state() {
|
||||||
|
|
||||||
void LineEdit::_bind_methods() {
|
void LineEdit::_bind_methods() {
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("_text_changed"), &LineEdit::_text_changed);
|
||||||
ClassDB::bind_method(D_METHOD("_toggle_draw_caret"), &LineEdit::_toggle_draw_caret);
|
ClassDB::bind_method(D_METHOD("_toggle_draw_caret"), &LineEdit::_toggle_draw_caret);
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
@ -1458,6 +1471,7 @@ LineEdit::LineEdit() {
|
||||||
window_has_focus = true;
|
window_has_focus = true;
|
||||||
max_length = 0;
|
max_length = 0;
|
||||||
pass = false;
|
pass = false;
|
||||||
|
text_changed_dirty = false;
|
||||||
placeholder_alpha = 0.6;
|
placeholder_alpha = 0.6;
|
||||||
|
|
||||||
deselect();
|
deselect();
|
||||||
|
|
|
@ -67,6 +67,7 @@ private:
|
||||||
|
|
||||||
bool editable;
|
bool editable;
|
||||||
bool pass;
|
bool pass;
|
||||||
|
bool text_changed_dirty;
|
||||||
|
|
||||||
String undo_text;
|
String undo_text;
|
||||||
String text;
|
String text;
|
||||||
|
|
Loading…
Reference in New Issue