From 8a1b1ab6d6cec2bc2eb3206a6663873dc62ef040 Mon Sep 17 00:00:00 2001 From: George Marques Date: Fri, 17 Jun 2016 20:21:14 -0300 Subject: [PATCH 1/2] Add button_down and button_up signals --- scene/gui/base_button.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 41d766c1b73..6479dd2d02a 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -55,6 +55,8 @@ void BaseButton::_input_event(InputEvent p_event) { if (b.pressed) { + emit_signal("button_down"); + if (!toggle_mode) { //mouse press attempt status.press_attempt=true; @@ -86,6 +88,8 @@ void BaseButton::_input_event(InputEvent p_event) { } else { + emit_signal("button_up"); + if (status.press_attempt && status.pressing_inside) { // released(); emit_signal("released"); @@ -100,9 +104,11 @@ void BaseButton::_input_event(InputEvent p_event) { status.press_attempt=true; status.pressing_inside=true; + emit_signal("button_down"); } else { + emit_signal("button_up"); if (status.press_attempt &&status.pressing_inside) { @@ -173,6 +179,7 @@ void BaseButton::_input_event(InputEvent p_event) { status.pressing_button++; status.press_attempt=true; status.pressing_inside=true; + emit_signal("button_down"); } else if (status.press_attempt) { @@ -185,6 +192,8 @@ void BaseButton::_input_event(InputEvent p_event) { status.press_attempt=false; status.pressing_inside=false; + emit_signal("button_up"); + if (!toggle_mode) { //mouse press attempt pressed(); @@ -467,6 +476,8 @@ void BaseButton::_bind_methods() { ADD_SIGNAL( MethodInfo("pressed" ) ); ADD_SIGNAL( MethodInfo("released" ) ); + ADD_SIGNAL( MethodInfo("button_up") ); + ADD_SIGNAL( MethodInfo("button_down") ); ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) ); ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled")); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode")); From 141360ed82c2eff634cdee3a7823465937876484 Mon Sep 17 00:00:00 2001 From: George Marques Date: Fri, 17 Jun 2016 20:35:27 -0300 Subject: [PATCH 2/2] Better document the BaseButton signals --- doc/base/classes.xml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 4b6f5f510df..ca2e9dafc96 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -5922,14 +5922,24 @@ + + + Emitted when the button starts being held down. + + + + + Emitted when the button stops being held down. + + - This signal is emitted every time the button is pressed or toggled. + This signal is emitted every time the button is toggled or pressed (i.e. activated, so on [code]button_down[/code] if "Click on press" is active and on [code]button_up[/code] otherwise). - This signal is emitted when the button was released. + Emitted when the button was released. This is only emitted by non-toggle buttons and if "Click on press" is active.