Skip to content

Commit

Permalink
Automatically update list when search string is changed in addons_screen
Browse files Browse the repository at this point in the history
  • Loading branch information
heuchi committed May 22, 2021
1 parent 2f98a01 commit d4ad37e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/states_screens/addons_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion src/states_screens/addons_screen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand All @@ -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:
Expand Down Expand Up @@ -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();

};
Expand Down

0 comments on commit d4ad37e

Please sign in to comment.