summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorConteZero <one@contezero.com>2021-10-28 09:07:18 +0200
committerConteZero <one@contezero.com>2021-11-15 17:10:56 +0100
commit2b1787b446edb31e4e6812552e556a4df412fe27 (patch)
treef6e42d52f06a8e0e6bafdd20a54fd03105193b3c /scene/main
parentb6c002f32d3ee01f227dbaaf15caf5ce378f2fb6 (diff)
Fix drag and drop on LineEdit
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/viewport.cpp11
-rw-r--r--scene/main/viewport.h2
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);