Automatically update list when search string is changed in addons_screen

This commit is contained in:
Heuchi 2021-05-22 13:05:01 +02:00
parent 2f98a011d4
commit d4ad37e6c6
2 changed files with 12 additions and 1 deletions

View File

@ -170,6 +170,9 @@ void AddonsScreen::init()
GUIEngine::TextBoxWidget* w_filter_name =
getWidget<GUIEngine::TextBoxWidget>("filter_name");
w_filter_name->setText(L"");
// Add listener for incremental update when search text is changed
w_filter_name->clearListeners();
w_filter_name->addListener(this);
GUIEngine::SpinnerWidget* w_filter_date =
getWidget<GUIEngine::SpinnerWidget>("filter_date");
w_filter_date->setValue(0);

View File

@ -21,6 +21,7 @@
#include "addons/addons_manager.hpp"
#include "guiengine/screen.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "states_screens/dialogs/addons_loading.hpp"
/* used for the installed/unsinstalled icons*/
@ -41,7 +42,8 @@ struct DateFilter {
*/
class AddonsScreen : public GUIEngine::Screen,
public GUIEngine::ScreenSingleton<AddonsScreen>,
public GUIEngine::IListWidgetHeaderListener
public GUIEngine::IListWidgetHeaderListener,
public GUIEngine::ITextBoxWidgetListener
{
friend class GUIEngine::ScreenSingleton<AddonsScreen>;
private:
@ -103,6 +105,12 @@ public:
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void onUpdate(float dt) OVERRIDE;
/** \brief rebuild the list based on search text */
virtual void onTextUpdated() OVERRIDE
{
loadList();
}
void setLastSelected();
};