-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make setting FilteredList.edit.setText('')
optional in FilteredList:setChoices
?
#4983
Comments
The interaction between the filter and The "best" approach that I've been able to come up with is this sequence of calls: local saved_filter = list:getFilter()
list:setFilter('')
list:setChoices(self:get_choices(), list:getSelected())
list:setFilter(saved_filter) I suspect that this is probably what should happen automatically when you call |
Ah yeah, that's a much better workaround. Thanks! I was trying to do:
This made sense to me because I wasn't accounting for Now I am doing:
I think I would still benefit slightly from being able to call
I still think it might be slightly unintuitive having to ensure that I restore the filter before calling |
I ran into a situation where this line of code was causing me some confusion.
I have a script that has a bunch of tabs that determine the current "view" and "subview". For e.g. Citizens -> Adults, Animals -> Wild. There is a single
FilteredList
that displays the units matching the filters determined by view/subview + a filter that the user provides in theFilteredList.edit
.The
FilteredList
has anedit_on_change
callback that stores the value of the filter when it is changed. The purpose of this is to keep track of the current filter as you switch between views and restore them. So in the above screenshot, if I click away to a different tab and then switch back to Citizens -> Adults, I want the filter to be "adil" again.When I switch views, I call
FilteredList:setChoices(newChoices)
. This causesFilteredList.edit.setText('')
to be executed, which causesedit_on_change
to trigger which is causing my filter cache to be updated to''
for that view/subview as well.I think it should maybe be possible to call this method without resetting the edit value.
One way I can think to work around this for now would be to set some global variable before I call
FilteredList:setChoices(newChoices)
, check the value in myedit_on_change
callback to determine if it should be executed, then set the value back after the call.The text was updated successfully, but these errors were encountered: