From ce9d05ec7beb9ca4280b79e7252425cdb2f9c7f1 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 29 Oct 2018 19:10:42 +0100 Subject: [PATCH] Fix FListBox prevListItem() + nextListItem() --- src/flistbox.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 3baa61c5..83bae776 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -1532,17 +1532,17 @@ void FListBox::prevListItem (int distance) if ( current == 1 ) return; - if ( current < std::size_t(distance) ) + if ( current <= std::size_t(distance) ) current = 1; else current -= std::size_t(distance); if ( current <= std::size_t(yoffset) ) { - yoffset -= distance; - - if ( yoffset < 0 ) + if ( yoffset < distance ) yoffset = 0; + else + yoffset -= distance; } } @@ -1555,17 +1555,17 @@ void FListBox::nextListItem (int distance) if ( current == element_count ) return; - current += std::size_t(distance); - - if ( current > element_count ) + if ( current + std::size_t(distance) > element_count ) current = element_count; + else + current += std::size_t(distance); if ( current - std::size_t(yoffset) > getClientHeight() ) { - yoffset += distance; - - if ( yoffset > yoffset_end ) + if ( yoffset > yoffset_end - distance ) yoffset = yoffset_end; + else + yoffset += distance; } } //----------------------------------------------------------------------