ListBox attributes controlling self:dismiss()

`dismiss_on_submit = false` makes it easier to implement toggleable options, where we don't want the list to disappear on selection. Like work order conditions' trait selection.
develop
Timur Kelman 2021-07-29 19:00:19 +02:00 committed by GitHub
parent 43d7905227
commit ffecdf3b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

@ -150,6 +150,8 @@ ListBox.focus_path = 'ListBox'
ListBox.ATTRS{ ListBox.ATTRS{
with_filter = false, with_filter = false,
dismiss_on_submit = true,
dismiss_on_submit2 = true,
cursor_pen = DEFAULT_NIL, cursor_pen = DEFAULT_NIL,
select_pen = DEFAULT_NIL, select_pen = DEFAULT_NIL,
on_select = DEFAULT_NIL, on_select = DEFAULT_NIL,
@ -174,7 +176,7 @@ function ListBox:init(info)
local on_submit2 local on_submit2
if self.select2_hint or self.on_select2 then if self.select2_hint or self.on_select2 then
on_submit2 = function(sel, obj) on_submit2 = function(sel, obj)
self:dismiss() if self.dismiss_on_submit2 then self:dismiss() end
if self.on_select2 then self.on_select2(sel, obj) end if self.on_select2 then self.on_select2(sel, obj) end
local cb = obj.on_select2 local cb = obj.on_select2
if cb then cb(obj, sel) end if cb then cb(obj, sel) end
@ -190,7 +192,7 @@ function ListBox:init(info)
text_pen = spen, text_pen = spen,
cursor_pen = cpen, cursor_pen = cpen,
on_submit = function(sel,obj) on_submit = function(sel,obj)
self:dismiss() if self.dismiss_on_submit then self:dismiss() end
if self.on_select then self.on_select(sel, obj) end if self.on_select then self.on_select(sel, obj) end
local cb = obj.on_select or obj[2] local cb = obj.on_select or obj[2]
if cb then cb(obj, sel) end if cb then cb(obj, sel) end