From 7ede2f36fe0061b38d4d37869f41187c91437faf Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 13 Dec 2020 20:16:56 +0100 Subject: [PATCH] Allow to override drop data in LineEdit (cherry picked from commit a3a31591b53da6a79f37760d0e7ee34d6d4e4ee6) --- scene/gui/control.cpp | 2 +- scene/gui/line_edit.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index e966cb35684..829daedd25c 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -754,7 +754,7 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const return ret; } - return Variant(); + return false; } void Control::drop_data(const Point2 &p_point, const Variant &p_data) { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index fe2d6207a57..45c9b81737f 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -611,11 +611,18 @@ Variant LineEdit::get_drag_data(const Point2 &p_point) { return Variant(); } + bool LineEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const { + bool drop_override = Control::can_drop_data(p_point, p_data); // In case user wants to drop custom data. + if (drop_override) { + return drop_override; + } return p_data.get_type() == Variant::STRING; } + void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { + Control::drop_data(p_point, p_data); if (p_data.get_type() == Variant::STRING) { set_cursor_at_pixel_pos(p_point.x);