Merge pull request #2891 from robob27/filteredlist-on-change

Add edit_on_change to FilteredList
develop
Myk 2023-02-12 18:41:41 -08:00 committed by GitHub
commit 8dd938c5a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

@ -54,6 +54,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Lua
- ``widgets.FilteredList``: Added ``edit_on_change`` optional parameter to allow a custom callback on filter edit change.
## Removed
# 50.07-alpha1

@ -4975,6 +4975,7 @@ supports:
:edit_below: If true, the edit field is placed below the list instead of above.
:edit_key: If specified, the edit field is disabled until this key is pressed.
:edit_ignore_keys: If specified, will be passed to the filter edit field as its ``ignore_keys`` attribute.
:edit_on_change: If specified, will be passed to the filter edit field as its ``on_change`` attribute.
:edit_on_char: If specified, will be passed to the filter edit field as its ``on_char`` attribute.
:not_found_label: Specifies the text of the label shown when no items match the filter.

@ -1887,6 +1887,7 @@ FilteredList.ATTRS {
edit_key = DEFAULT_NIL,
edit_ignore_keys = DEFAULT_NIL,
edit_on_char = DEFAULT_NIL,
edit_on_change = DEFAULT_NIL,
}
function FilteredList:init(info)
@ -1897,10 +1898,18 @@ function FilteredList:init(info)
end
end
local on_change = self:callback('onFilterChange')
if self.edit_on_change then
on_change = function(text)
self.edit_on_change(text)
self:onFilterChange(text)
end
end
self.edit = EditField{
text_pen = info.edit_pen or info.cursor_pen,
frame = { l = info.icon_width, t = 0, h = 1 },
on_change = self:callback('onFilterChange'),
on_change = on_change,
on_char = on_char,
key = self.edit_key,
ignore_keys = self.edit_ignore_keys,