diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 9a863ab86b0..5afbad090bf 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -5018,7 +5018,7 @@ - Return when the button is pressed (only if toggle_mode is active). + If toggle_mode is active, return whether the button is toggled. If toggle_mode is not active, return whether the button is pressed down. diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 965e7f399dd..0c63a3bc74b 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -255,6 +255,16 @@ void BaseButton::_notification(int p_what) { group->_remove_button(this); } + if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible()) { + + if (!toggle_mode) { + status.pressed = false; + } + status.hovering = false; + status.press_attempt = false; + status.pressing_inside = false; + status.pressing_button = 0; + } } void BaseButton::pressed() {