@@ -144,8 +144,6 @@ void SpinBox::_text_submitted(const String &p_string) {
144144
145145 Error err = expr->parse (text);
146146
147- use_custom_arrow_step = false ;
148-
149147 if (err != OK) {
150148 // If the expression failed try without converting commas to dots - they might have been for parameter separation.
151149 text = p_string;
@@ -195,12 +193,12 @@ void SpinBox::_range_click_timeout() {
195193 bool mouse_on_up_button = get_local_mouse_position ().y < (get_size ().height / 2 );
196194 // Arrow button is being pressed. Snap the value to next step.
197195 double temp_step = get_custom_arrow_step () != 0.0 ? get_custom_arrow_step () : get_step ();
196+ temp_step = Math::snapped (temp_step, get_step ());
198197 double new_value = _calc_value (get_value (), temp_step);
199198 if ((mouse_on_up_button && new_value <= get_value () + CMP_EPSILON) || (!mouse_on_up_button && new_value >= get_value () - CMP_EPSILON)) {
200199 new_value = _calc_value (get_value () + (mouse_on_up_button ? temp_step : -temp_step), temp_step);
201200 }
202201 set_value (new_value);
203- use_custom_arrow_step = true ;
204202
205203 if (range_click_timer->is_one_shot ()) {
206204 range_click_timer->set_wait_time (0.075 );
@@ -264,12 +262,12 @@ void SpinBox::gui_input(const Ref<InputEvent> &p_event) {
264262 if (mouse_on_up_button || mouse_on_down_button) {
265263 // Arrow button is being pressed. Snap the value to next step.
266264 double temp_step = get_custom_arrow_step () != 0.0 ? get_custom_arrow_step () : get_step ();
265+ temp_step = Math::snapped (temp_step, get_step ());
267266 double new_value = _calc_value (get_value (), temp_step);
268267 if ((mouse_on_up_button && new_value <= get_value () + CMP_EPSILON) || (!mouse_on_up_button && new_value >= get_value () - CMP_EPSILON)) {
269268 new_value = _calc_value (get_value () + (mouse_on_up_button ? temp_step : -temp_step), temp_step);
270269 }
271270 set_value (new_value);
272- use_custom_arrow_step = true ;
273271 }
274272 state_cache.up_button_pressed = mouse_on_up_button;
275273 state_cache.down_button_pressed = mouse_on_down_button;
@@ -285,20 +283,17 @@ void SpinBox::gui_input(const Ref<InputEvent> &p_event) {
285283 case MouseButton::RIGHT: {
286284 line_edit->grab_focus ();
287285 if (mouse_on_up_button || mouse_on_down_button) {
288- use_custom_arrow_step = false ;
289286 set_value (mouse_on_up_button ? get_max () : get_min ());
290287 }
291288 } break ;
292289 case MouseButton::WHEEL_UP: {
293290 if (line_edit->is_editing ()) {
294- use_custom_arrow_step = false ;
295291 set_value (get_value () + step * mb->get_factor ());
296292 accept_event ();
297293 }
298294 } break ;
299295 case MouseButton::WHEEL_DOWN: {
300296 if (line_edit->is_editing ()) {
301- use_custom_arrow_step = false ;
302297 set_value (get_value () - step * mb->get_factor ());
303298 accept_event ();
304299 }
@@ -338,7 +333,6 @@ void SpinBox::gui_input(const Ref<InputEvent> &p_event) {
338333 if (drag.enabled ) {
339334 drag.diff_y += mm->get_relative ().y ;
340335 double diff_y = -0.01 * Math::pow (Math::abs (drag.diff_y ), 1.8 ) * SIGN (drag.diff_y );
341- use_custom_arrow_step = false ;
342336 set_value (CLAMP (drag.base_val + step * diff_y, get_min (), get_max ()));
343337 } else if (drag.allowed && drag.capture_pos .distance_to (mm->get_position ()) > 2 ) {
344338 Input::get_singleton ()->set_mouse_mode (Input::MOUSE_MODE_CAPTURED);
0 commit comments