Skip to content

Commit

Permalink
fix bug #22984: sliders not adjustable with arrow keys
Browse files Browse the repository at this point in the history
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.

cf84e1d
4961459

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
  • Loading branch information
cbeck88 committed Mar 5, 2015
1 parent 1c1ea67 commit e1102b3
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/widgets/slider.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e1102b3

Please sign in to comment.