1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Ensure slider grabs focus only when it can

This commit is contained in:
Ricardo Subtil
2023-12-02 11:06:06 +00:00
parent 6afd320984
commit fde51aeb28

View File

@@ -88,10 +88,14 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
} }
} else if (scrollable) { } else if (scrollable) {
if (mb->is_pressed() && mb->get_button_index() == MouseButton::WHEEL_UP) { if (mb->is_pressed() && mb->get_button_index() == MouseButton::WHEEL_UP) {
if (get_focus_mode() != FOCUS_NONE) {
grab_focus(); grab_focus();
}
set_value(get_value() + get_step()); set_value(get_value() + get_step());
} else if (mb->is_pressed() && mb->get_button_index() == MouseButton::WHEEL_DOWN) { } else if (mb->is_pressed() && mb->get_button_index() == MouseButton::WHEEL_DOWN) {
if (get_focus_mode() != FOCUS_NONE) {
grab_focus(); grab_focus();
}
set_value(get_value() - get_step()); set_value(get_value() - get_step());
} }
} }