mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-03 14:52:11 +02:00
search box scroll fix
This commit is contained in:
parent
d4b2ec5b0b
commit
28fd6c50c4
@ -1508,7 +1508,7 @@ CObjectListWindow::CObjectListWindow(const std::vector<int> & _items, std::share
|
||||
itemsVisible = items;
|
||||
|
||||
init(titleWidget_, _title, _descr, searchBoxEnabled);
|
||||
list->scrollTo(initialSelection - 4); // -4 is for centering (list have 9 elements)
|
||||
list->scrollTo(std::min(static_cast<int>(initialSelection + 4), static_cast<int>(items.size() - 1))); // 4 is for centering (list have 9 elements)
|
||||
}
|
||||
|
||||
CObjectListWindow::CObjectListWindow(const std::vector<std::string> & _items, std::shared_ptr<CIntObject> titleWidget_, std::string _title, std::string _descr, std::function<void(int)> Callback, size_t initialSelection, std::vector<std::shared_ptr<IImage>> images, bool searchBoxEnabled)
|
||||
@ -1528,7 +1528,7 @@ CObjectListWindow::CObjectListWindow(const std::vector<std::string> & _items, st
|
||||
itemsVisible = items;
|
||||
|
||||
init(titleWidget_, _title, _descr, searchBoxEnabled);
|
||||
list->scrollTo(initialSelection - 4); // -4 is for centering (list have 9 elements)
|
||||
list->scrollTo(std::min(static_cast<int>(initialSelection + 4), static_cast<int>(items.size() - 1))); // 4 is for centering (list have 9 elements)
|
||||
}
|
||||
|
||||
void CObjectListWindow::init(std::shared_ptr<CIntObject> titleWidget_, std::string _title, std::string _descr, bool searchBoxEnabled)
|
||||
@ -1653,7 +1653,7 @@ void CObjectListWindow::keyPressed(EShortcut key)
|
||||
}
|
||||
|
||||
vstd::abetween<int>(sel, 0, itemsVisible.size()-1);
|
||||
list->scrollTo(sel - 4); // -4 is for centering (list have 9 elements)
|
||||
list->scrollTo(sel);
|
||||
changeSelection(sel);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user