diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-17 11:31:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-17 11:31:47 +0300 |
commit | 693879649420c0997bfb29bea7f5752f6d9ac526 (patch) | |
tree | 01d6c56532d561385edbfe2ad0235df6c5a58c5f /src/gui/widgets/slider.cpp | |
parent | 8df35828d69f3debd89557a74c26359a8b249f87 (diff) | |
download | plus-693879649420c0997bfb29bea7f5752f6d9ac526.tar.gz plus-693879649420c0997bfb29bea7f5752f6d9ac526.tar.bz2 plus-693879649420c0997bfb29bea7f5752f6d9ac526.tar.xz plus-693879649420c0997bfb29bea7f5752f6d9ac526.zip |
Move keyboard handling from guichan to own classes.
Diffstat (limited to 'src/gui/widgets/slider.cpp')
-rw-r--r-- | src/gui/widgets/slider.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 7142cd202..24a2a5128 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -297,3 +297,39 @@ void Slider::mouseExited(gcn::MouseEvent& event A_UNUSED) { mHasMouse = false; } + +void Slider::keyPressed(gcn::KeyEvent& keyEvent) +{ + gcn::Key key = keyEvent.getKey(); + + if (getOrientation() == HORIZONTAL) + { + if (key.getValue() == gcn::Key::RIGHT) + { + setValue(getValue() + getStepLength()); + distributeActionEvent(); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::LEFT) + { + setValue(getValue() - getStepLength()); + distributeActionEvent(); + keyEvent.consume(); + } + } + else + { + if (key.getValue() == gcn::Key::UP) + { + setValue(getValue() + getStepLength()); + distributeActionEvent(); + keyEvent.consume(); + } + else if (key.getValue() == gcn::Key::DOWN) + { + setValue(getValue() - getStepLength()); + distributeActionEvent(); + keyEvent.consume(); + } + } +} |