mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix SpinBox value change when held down on separation between buttons
This commit is contained in:
parent
825ef2387f
commit
c6be28af7a
1 changed files with 17 additions and 8 deletions
|
@ -190,7 +190,15 @@ void SpinBox::_line_edit_input(const Ref<InputEvent> &p_event) {
|
||||||
|
|
||||||
void SpinBox::_range_click_timeout() {
|
void SpinBox::_range_click_timeout() {
|
||||||
if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT)) {
|
if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT)) {
|
||||||
bool mouse_on_up_button = get_local_mouse_position().y < (get_size().height / 2);
|
Rect2 up_button_rc = Rect2(sizing_cache.buttons_left, 0, sizing_cache.buttons_width, sizing_cache.button_up_height);
|
||||||
|
Rect2 down_button_rc = Rect2(sizing_cache.buttons_left, sizing_cache.second_button_top, sizing_cache.buttons_width, sizing_cache.button_down_height);
|
||||||
|
|
||||||
|
Vector2 mpos = get_local_mouse_position();
|
||||||
|
|
||||||
|
bool mouse_on_up_button = up_button_rc.has_point(mpos);
|
||||||
|
bool mouse_on_down_button = down_button_rc.has_point(mpos);
|
||||||
|
|
||||||
|
if (mouse_on_up_button || mouse_on_down_button) {
|
||||||
// Arrow button is being pressed. Snap the value to next step.
|
// Arrow button is being pressed. Snap the value to next step.
|
||||||
double temp_step = get_custom_arrow_step() != 0.0 ? get_custom_arrow_step() : get_step();
|
double temp_step = get_custom_arrow_step() != 0.0 ? get_custom_arrow_step() : get_step();
|
||||||
temp_step = Math::snapped(temp_step, get_step());
|
temp_step = Math::snapped(temp_step, get_step());
|
||||||
|
@ -199,6 +207,7 @@ void SpinBox::_range_click_timeout() {
|
||||||
new_value = _calc_value(get_value() + (mouse_on_up_button ? temp_step : -temp_step), temp_step);
|
new_value = _calc_value(get_value() + (mouse_on_up_button ? temp_step : -temp_step), temp_step);
|
||||||
}
|
}
|
||||||
set_value(new_value);
|
set_value(new_value);
|
||||||
|
}
|
||||||
|
|
||||||
if (range_click_timer->is_one_shot()) {
|
if (range_click_timer->is_one_shot()) {
|
||||||
range_click_timer->set_wait_time(0.075);
|
range_click_timer->set_wait_time(0.075);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue