diff options
Diffstat (limited to 'gui/ListWidget.cpp')
-rw-r--r-- | gui/ListWidget.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 3b1ff3df70..0af09fbfb5 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -65,6 +65,20 @@ void ListWidget::setList(const StringList& list) scrollBarRecalc(); } +void ListWidget::scrollTo(int item) +{ + int size = _list.size(); + if (item >= size) + item = size - 1; + else if (item < 0) + item = 0; + + if (_currentPos != item) { + _currentPos = item; + scrollBarRecalc(); + } +} + void ListWidget::scrollBarRecalc() { _scrollBar->_numEntries = _list.size(); |