From: Mikko Rasa Date: Fri, 6 Mar 2015 00:02:06 +0000 (+0200) Subject: Implement mouse wheel scrolling in List X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f0b600c3b1739f7e088da6ab8eb7c2e67adf592c;p=libs%2Fgltk.git Implement mouse wheel scrolling in List --- diff --git a/source/list.cpp b/source/list.cpp index 10c5af8..f61d7c2 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -215,15 +215,32 @@ void List::render_special(const Part &part, GL::Renderer &renderer) const void List::button_press(int x, int y, unsigned btn) { - Container::button_press(x, y, btn); - if(click_focus && btn==1) + if(btn==4 || btn==5) { - for(unsigned i=first; (iis_visible()); ++i) - if(click_focus==items[i]) - { - set_selected_index(i); - break; - } + unsigned change = 3; + if(btn==4) + { + change = min(first, change); + slider.set_value(max_scroll-(first-change)); + } + else if(btn==5) + { + change = min(max_scroll-first, change); + slider.set_value(max_scroll-(first+change)); + } + } + else + { + Container::button_press(x, y, btn); + if(click_focus && btn==1) + { + for(unsigned i=first; (iis_visible()); ++i) + if(click_focus==items[i]) + { + set_selected_index(i); + break; + } + } } }