summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-02-13 22:14:25 +0100
committerGitHub <noreply@github.com>2018-02-13 22:14:25 +0100
commit89447739347b0e9226c5eff0797c72760f422f48 (patch)
treefdb5587da920a141dc509c0baec7463f971eb8bb /scene
parente8763ef1306b0d87df742cfc0636ea75f4a12bce (diff)
parent9cd3ed4acef91ee7dcef1db2edfe3e40d6838656 (diff)
Merge pull request #16422 from synasius/fixed-line-edit-text-changed-signal
Fixed #15082: line edit emits two "text_changed" signals when pasting while text is selected
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/line_edit.cpp18
-rw-r--r--scene/gui/line_edit.h1
2 files changed, 17 insertions, 2 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 524a68a116..03dc6686b8 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -30,6 +30,7 @@
#include "line_edit.h"
#include "label.h"
+#include "message_queue.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "print_string.h"
@@ -800,7 +801,12 @@ void LineEdit::paste_text() {
if (selection.enabled) selection_delete();
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;
}
- _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) {
@@ -1341,6 +1352,7 @@ void LineEdit::_text_changed() {
void LineEdit::_emit_text_change() {
emit_signal("text_changed", text);
_change_notify("text");
+ text_changed_dirty = false;
}
void LineEdit::_clear_redo() {
@@ -1373,6 +1385,7 @@ void LineEdit::_create_undo_state() {
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);
#ifdef TOOLS_ENABLED
@@ -1458,6 +1471,7 @@ LineEdit::LineEdit() {
window_has_focus = true;
max_length = 0;
pass = false;
+ text_changed_dirty = false;
placeholder_alpha = 0.6;
deselect();
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index e15980d3c4..e3ad3b17f1 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -67,6 +67,7 @@ private:
bool editable;
bool pass;
+ bool text_changed_dirty;
String undo_text;
String text;