Allow to override drop data in LineEdit

(cherry picked from commit a3a31591b5)
This commit is contained in:
kobewi 2020-12-13 20:16:56 +01:00 committed by Rémi Verschelde
parent 0ff0fdef5c
commit 7ede2f36fe
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 8 additions and 1 deletions

View file

@ -754,7 +754,7 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const
return ret; return ret;
} }
return Variant(); return false;
} }
void Control::drop_data(const Point2 &p_point, const Variant &p_data) { void Control::drop_data(const Point2 &p_point, const Variant &p_data) {

View file

@ -611,11 +611,18 @@ Variant LineEdit::get_drag_data(const Point2 &p_point) {
return Variant(); return Variant();
} }
bool LineEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const { 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; return p_data.get_type() == Variant::STRING;
} }
void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { 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) { if (p_data.get_type() == Variant::STRING) {
set_cursor_at_pixel_pos(p_point.x); set_cursor_at_pixel_pos(p_point.x);