Skip to content

Conversation

Giganzo
Copy link
Contributor

@Giganzo Giganzo commented Sep 2, 2025

Fixes: #110211

Before:

Screencast_20250902_230836.webm

After:

Screencast_20250902_230734.webm

@Giganzo Giganzo requested a review from a team as a code owner September 2, 2025 21:42
@KoBeWi KoBeWi added this to the 4.6 milestone Sep 2, 2025
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working as expected, the same code is used for hover/initial press detection.

diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index c3632ae4a8..60b23b4a30 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -203,7 +203,7 @@ void SpinBox::_range_click_timeout() {
                        double temp_step = get_custom_arrow_step() != 0.0 ? get_custom_arrow_step() : get_step();
                        temp_step = Math::snapped(temp_step, get_step());
                        double new_value = _calc_value(get_value(), temp_step);
-                       if ((mouse_on_up_button && new_value <= get_value() + CMP_EPSILON) || (!mouse_on_up_button && new_value >= get_value() - CMP_EPSILON)) {
+                       if ((mouse_on_up_button && new_value <= get_value() + CMP_EPSILON) || (mouse_on_down_button && new_value >= get_value() - CMP_EPSILON)) {
                                new_value = _calc_value(get_value() + (mouse_on_up_button ? temp_step : -temp_step), temp_step);
                        }
                        set_value(new_value);
@@ -273,7 +273,7 @@ void SpinBox::gui_input(const Ref<InputEvent> &p_event) {
                                        double temp_step = get_custom_arrow_step() != 0.0 ? get_custom_arrow_step() : get_step();
                                        temp_step = Math::snapped(temp_step, get_step());
                                        double new_value = _calc_value(get_value(), temp_step);
-                                       if ((mouse_on_up_button && new_value <= get_value() + CMP_EPSILON) || (!mouse_on_up_button && new_value >= get_value() - CMP_EPSILON)) {
+                                       if ((mouse_on_up_button && new_value <= get_value() + CMP_EPSILON) || (mouse_on_down_button && new_value >= get_value() - CMP_EPSILON)) {
                                                new_value = _calc_value(get_value() + (mouse_on_up_button ? temp_step : -temp_step), temp_step);
                                        }
                                        set_value(new_value);

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected. Code looks good to me.

Preview with crosshair cursor, so you can see the click area is well-aligned:

spinbox_after.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SpinBox stepper hold down state can be triggered on the separation between buttons.
4 participants