You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for BaseButton.button_pressed has a note that says:
Note: Setting button_pressed will result in toggled to be emitted. If you want to change the pressed state without emitting that signal, use set_pressed_no_signal().
To me this read as "Setting button_pressed will always result in toggled to be emitted".
However the actual behavior is that the toggled signal is only emitted when button_pressed is set to a different value (!button_pressed).
You can see in line 217 the function returns early if status.pressed == prev_pressed and _toggled(status.pressed) is never reached
Users might think that setting button_pressed in code will force the emission of the toggled signal, even if they set it to the same value.
I'm not sure if the documentation or the implementation need to be changed. I assume it makes sense that "toggled" is only emitted when there is an actual toggle of the button_pressed boolean and at the same time changing the implementation is a breaking change.
Steps to reproduce
Create a button
Connect any callback to its "toggled" signal
In a script set the button's "button_pressed" property to the same value it already has
Expected: the callback gets called
Actual: the callback doesn't get called
Tested versions
System information
Godot v4.3.stable - Windows 10.0.22631 - GLES3 (Compatibility) - AMD Radeon RX 6700S (Advanced Micro Devices, Inc.; 32.0.11037.4004) - AMD Ryzen 9 6900HS with Radeon Graphics (16 Threads)
Issue description
The documentation for BaseButton.button_pressed has a note that says:
To me this read as "Setting button_pressed will always result in toggled to be emitted".
However the actual behavior is that the toggled signal is only emitted when button_pressed is set to a different value (!button_pressed).
You can see in line 217 the function returns early if status.pressed == prev_pressed and _toggled(status.pressed) is never reached
godot/scene/gui/base_button.cpp
Lines 213 to 228 in 0a4aedb
Users might think that setting button_pressed in code will force the emission of the toggled signal, even if they set it to the same value.
I'm not sure if the documentation or the implementation need to be changed. I assume it makes sense that "toggled" is only emitted when there is an actual toggle of the button_pressed boolean and at the same time changing the implementation is a breaking change.
Steps to reproduce
Expected: the callback gets called
Actual: the callback doesn't get called
Minimal reproduction project (MRP)
button_toggled_same_state_no_signal_mrp.zip
The text was updated successfully, but these errors were encountered: