fix bug #22984: sliders not adjustable with arrow keys
This commit causes sliders to attract focus properly when their grips are clicked on, and to respond to left and right arrow presses again. It partly reverts two earlier commits that affected this functionality.cf84e1d8aa
49614599fa
It causes the zoom slider to behave slightly badly, because it does not lose focus when the user clicks elsewhere on the map. But this bug should be fixed at the source and not by disabling wanted functionality for all sliders. Conflicts: src/widgets/slider.cpp
This commit is contained in:
parent
1c1ea67710
commit
e1102b394f
1 changed files with 14 additions and 15 deletions
|
@ -239,11 +239,11 @@ void slider::mouse_down(const SDL_MouseButtonEvent& event)
|
|||
return;
|
||||
|
||||
state_ = CLICKED;
|
||||
set_focus(true);
|
||||
if (point_in_rect(event.x, event.y, slider_area())) {
|
||||
sound::play_UI_sound(game_config::sounds::button_press);
|
||||
} else {
|
||||
value_change_ = false;
|
||||
set_focus(true);
|
||||
set_slider_position(event.x);
|
||||
if(value_change_) {
|
||||
sound::play_UI_sound(game_config::sounds::slider_adjust);
|
||||
|
@ -299,20 +299,19 @@ void slider::handle_event(const SDL_Event& event)
|
|||
if (!mouse_locked())
|
||||
mouse_motion(event.motion);
|
||||
break;
|
||||
//TODO enable if you know how to fix the zoom slider bug
|
||||
// case SDL_KEYDOWN:
|
||||
// if(focus(&event)) {
|
||||
// const SDL_keysym& key = reinterpret_cast<const SDL_KeyboardEvent&>(event).keysym;
|
||||
// const int c = key.sym;
|
||||
// if(c == SDLK_LEFT) {
|
||||
// sound::play_UI_sound(game_config::sounds::slider_adjust);
|
||||
// set_value(value_ - increment_);
|
||||
// } else if(c == SDLK_RIGHT) {
|
||||
// sound::play_UI_sound(game_config::sounds::slider_adjust);
|
||||
// set_value(value_ + increment_);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case SDL_KEYDOWN:
|
||||
if(focus(&event)) {
|
||||
const SDL_keysym& key = reinterpret_cast<const SDL_KeyboardEvent&>(event).keysym;
|
||||
const int c = key.sym;
|
||||
if(c == SDLK_LEFT) {
|
||||
sound::play_UI_sound(game_config::sounds::slider_adjust);
|
||||
set_value(value_ - increment_);
|
||||
} else if(c == SDLK_RIGHT) {
|
||||
sound::play_UI_sound(game_config::sounds::slider_adjust);
|
||||
set_value(value_ + increment_);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue