From 9e0b6057e74181635bf3732879313d3d82bcfd93 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 23 Jun 2016 18:20:39 -0300 Subject: Make button aware of it being dragged and reset state, closes #4178 --- scene/gui/base_button.cpp | 10 ++++++++++ scene/main/viewport.cpp | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'scene') diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index bc498f47bc..d7632b14b8 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -225,11 +225,21 @@ void BaseButton::_notification(int p_what) { status.hovering=false; update(); } + if (p_what==NOTIFICATION_DRAG_BEGIN) { + + if (status.press_attempt) { + status.press_attempt=false; + status.pressing_button=0; + update(); + } + } + if (p_what==NOTIFICATION_FOCUS_EXIT) { if (status.pressing_button && status.press_attempt) { status.press_attempt=false; status.pressing_button=0; + update(); } } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index a1df7062ea..3c52af1c1e 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1933,7 +1933,6 @@ void Viewport::_gui_input_event(InputEvent p_event) { } - if (over!=gui.mouse_over) { if (gui.mouse_over) -- cgit v1.2.3