From c66b4a56badc75fbd106e2a7019b6cb83972d677 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 8 May 2009 11:15:42 +0200 Subject: Fixed scroll wheel handling in list boxes The scroll wheel was changing the list box selection, which is somewhat unexpected. By not handling the event, it will be passed on to the parent ScrollArea and be handled appropriately. --- src/gui/widgets/listbox.cpp | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'src/gui/widgets/listbox.cpp') diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 753e6461..28a5a018 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -66,7 +66,6 @@ void ListBox::draw(gcn::Graphics *graphics) } } -// -- KeyListener notifications void ListBox::keyPressed(gcn::KeyEvent& keyEvent) { gcn::Key key = keyEvent.getKey(); @@ -105,31 +104,14 @@ void ListBox::keyPressed(gcn::KeyEvent& keyEvent) } } +// Don't do anything on scrollwheel. ScrollArea will deal with that. + void ListBox::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) { - if (isFocused()) - { - if (getSelected() > 0) - setSelected(getSelected() - 1); - else if (getSelected() == 0 && mWrappingEnabled) - setSelected(getListModel()->getNumberOfElements() - 1); - - mouseEvent.consume(); - } } void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) { - if (isFocused()) - { - if (getSelected() < (getListModel()->getNumberOfElements() - 1)) - setSelected(getSelected() + 1); - else if (getSelected() == (getListModel()->getNumberOfElements() - 1) && - mWrappingEnabled) - setSelected(0); - - mouseEvent.consume(); - } } void ListBox::mouseDragged(gcn::MouseEvent &event) -- cgit v1.2.3-70-g09d2