Ensure slider grabs focus only when it can

(cherry picked from commit fde51aeb28)
This commit is contained in:
Ricardo Subtil 2023-12-02 11:06:06 +00:00 committed by Rémi Verschelde
parent 261129496c
commit 7fd058a7fa
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 6 additions and 2 deletions

View File

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