From 72ee43e9470c6fdbc6ed7ff92b85dfa5062c5762 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 6 Jan 2015 18:51:37 +0000 Subject: Added separate event handlers for mouse button clicks and mouse wheel movement. --- src/ui/scrollpane.cc | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/ui/scrollpane.cc') diff --git a/src/ui/scrollpane.cc b/src/ui/scrollpane.cc index 48391c5..57c957f 100644 --- a/src/ui/scrollpane.cc +++ b/src/ui/scrollpane.cc @@ -65,24 +65,21 @@ void ScrollPane::set_offset(const int offset) scrollpane_offset = offset; } -bool ScrollPane::on_keypress(const int key, const unsigned int modifier) +bool ScrollPane::on_mousewheel(const math::Vector2f & direction) { // number of lines to scroll int alignmentmodifier =( (alignment() & AlignTop) == AlignTop) ? -1 : 1; - switch (key) { - - case 512 + SDL_BUTTON_WHEELUP: - inc_scroll(alignmentmodifier * scrollpane_offset); - return true; - break; - - case 512 + SDL_BUTTON_WHEELDOWN: - dec_scroll(alignmentmodifier * scrollpane_offset); - return true; - break; + if (direction.y() > 0 ) + { + inc_scroll(alignmentmodifier * scrollpane_offset); + return true; + } else if (direction.y() < 0 ) + { + dec_scroll(alignmentmodifier * scrollpane_offset); + return true; } - + return false; } -- cgit v1.2.3