From d4ad37e6c6af13aa332583c4d645f462bc0c9df7 Mon Sep 17 00:00:00 2001 From: Heuchi Date: Sat, 22 May 2021 13:05:01 +0200 Subject: [PATCH] Automatically update list when search string is changed in addons_screen --- src/states_screens/addons_screen.cpp | 3 +++ src/states_screens/addons_screen.hpp | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp index 919e4f96944..142fca0b9e8 100644 --- a/src/states_screens/addons_screen.cpp +++ b/src/states_screens/addons_screen.cpp @@ -170,6 +170,9 @@ void AddonsScreen::init() GUIEngine::TextBoxWidget* w_filter_name = getWidget("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("filter_date"); w_filter_date->setValue(0); diff --git a/src/states_screens/addons_screen.hpp b/src/states_screens/addons_screen.hpp index b9f68698447..8d929c040bb 100644 --- a/src/states_screens/addons_screen.hpp +++ b/src/states_screens/addons_screen.hpp @@ -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, - public GUIEngine::IListWidgetHeaderListener + public GUIEngine::IListWidgetHeaderListener, + public GUIEngine::ITextBoxWidgetListener { friend class GUIEngine::ScreenSingleton; private: @@ -103,6 +105,12 @@ class AddonsScreen : public GUIEngine::Screen, /** \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(); };