Fix SpinBox value change when held down on separation between buttons#110212
Merged
Repiteo merged 1 commit intogodotengine:masterfrom Oct 1, 2025
Merged
Fix SpinBox value change when held down on separation between buttons#110212Repiteo merged 1 commit intogodotengine:masterfrom
Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
bruvzg
approved these changes
Sep 3, 2025
Member
bruvzg
left a comment
There was a problem hiding this comment.
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);
Calinou
approved these changes
Sep 3, 2025
Member
Calinou
left a comment
There was a problem hiding this comment.
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
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #110211
Before:
Screencast_20250902_230836.webm
After:
Screencast_20250902_230734.webm