diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-11-22 12:20:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 12:20:01 +0100 |
commit | 78dbe4e3e47ce0d400acaaf224527f5d7b40a718 (patch) | |
tree | fd5a5e256ac63e31d5bff1892ff65b7da05fbe45 /scene/main | |
parent | a387094c25e8fba582f7a0b0c906f5d99ecf1aec (diff) | |
parent | 2b1787b446edb31e4e6812552e556a4df412fe27 (diff) |
Merge pull request #54339 from ConteZero/line_edit_drag_and_drop
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/viewport.cpp | 11 | ||||
-rw-r--r-- | scene/main/viewport.h | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 1ecc3c762a..48a672b310 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1515,8 +1515,9 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (gui.drag_data.get_type() != Variant::NIL && mb->get_button_index() == MouseButton::LEFT) { // Alternate drop use (when using force_drag(), as proposed by #5342). + gui.drag_successful = false; if (gui.mouse_focus) { - _gui_drop(gui.mouse_focus, pos, false); + gui.drag_successful = _gui_drop(gui.mouse_focus, pos, false); } gui.drag_data = Variant(); @@ -1534,8 +1535,9 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { _gui_cancel_tooltip(); } else { if (gui.drag_data.get_type() != Variant::NIL && mb->get_button_index() == MouseButton::LEFT) { + gui.drag_successful = false; if (gui.drag_mouse_over) { - _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, false); + gui.drag_successful = _gui_drop(gui.drag_mouse_over, gui.drag_mouse_over_pos, false); } Control *drag_preview = _gui_get_drag_preview(); @@ -2895,6 +2897,10 @@ bool Viewport::gui_is_dragging() const { return gui.dragging; } +bool Viewport::gui_is_drag_successful() const { + return gui.drag_successful; +} + void Viewport::set_input_as_handled() { _drop_physics_mouseover(); @@ -3534,6 +3540,7 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("gui_get_drag_data"), &Viewport::gui_get_drag_data); ClassDB::bind_method(D_METHOD("gui_is_dragging"), &Viewport::gui_is_dragging); + ClassDB::bind_method(D_METHOD("gui_is_drag_successful"), &Viewport::gui_is_drag_successful); ClassDB::bind_method(D_METHOD("set_disable_input", "disable"), &Viewport::set_disable_input); ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 5320aea02a..11b76b32eb 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -348,6 +348,7 @@ private: List<Control *> roots; int canvas_sort_index = 0; //for sorting items with canvas as root bool dragging = false; + bool drag_successful = false; bool embed_subwindows_hint = false; bool embedding_subwindows = false; @@ -556,6 +557,7 @@ public: bool is_handling_input_locally() const; bool gui_is_dragging() const; + bool gui_is_drag_successful() const; Control *gui_find_control(const Point2 &p_global); |