@@ -125,6 +125,7 @@ EditField.ATTRS{
125125 on_char = DEFAULT_NIL ,
126126 on_change = DEFAULT_NIL ,
127127 on_submit = DEFAULT_NIL ,
128+ key = DEFAULT_NIL ,
128129}
129130
130131function EditField :onRenderBody (dc )
@@ -135,8 +136,14 @@ function EditField:onRenderBody(dc)
135136 cursor = ' '
136137 end
137138 local txt = self .text .. cursor
138- if # txt > dc .width then
139- txt = string.char (27 ).. string.sub (txt , # txt - dc .width + 2 )
139+ local dx = dc .x
140+ if self .key then
141+ dc :key_string (self .key , ' ' )
142+ end
143+ dx = dc .x - dx
144+ local max_width = dc .width - dx
145+ if # txt > max_width then
146+ txt = string.char (27 ).. string.sub (txt , # txt - max_width + 2 )
140147 end
141148 dc :string (txt )
142149end
@@ -649,6 +656,7 @@ FilteredList = defclass(FilteredList, Widget)
649656
650657FilteredList .ATTRS {
651658 edit_below = false ,
659+ edit_key = DEFAULT_NIL ,
652660}
653661
654662function FilteredList :init (info )
@@ -657,6 +665,8 @@ function FilteredList:init(info)
657665 frame = { l = info .icon_width , t = 0 , h = 1 },
658666 on_change = self :callback (' onFilterChange' ),
659667 on_char = self :callback (' onFilterChar' ),
668+ key = self .edit_key ,
669+ active = (self .edit_key == nil ),
660670 }
661671 self .list = List {
662672 frame = { t = 2 },
@@ -701,10 +711,24 @@ function FilteredList:init(info)
701711 end
702712end
703713
714+ function FilteredList :onInput (keys )
715+ if self .edit_key and keys [self .edit_key ] and not self .edit .active then
716+ self .edit .active = true
717+ elseif keys .LEAVESCREEN and self .edit .active then
718+ self .edit .active = false
719+ else
720+ self :inputToSubviews (keys )
721+ end
722+ end
723+
704724function FilteredList :getChoices ()
705725 return self .choices
706726end
707727
728+ function FilteredList :getVisibleChoices ()
729+ return self .list .choices
730+ end
731+
708732function FilteredList :setChoices (choices , pos )
709733 choices = choices or {}
710734 self .choices = choices
0 commit comments