1
0
mirror of https://github.com/kepler155c/opus synced 2025-01-29 08:34:46 +00:00

Fix bug in CheckboxGrid

This commit is contained in:
Anavrins 2020-05-04 03:55:55 -04:00
parent 447f4daa92
commit e2ba9e2a03

View File

@ -11,11 +11,12 @@ end
UI.CheckboxGrid = class(UI.Grid) UI.CheckboxGrid = class(UI.Grid)
UI.CheckboxGrid.defaults = { UI.CheckboxGrid.defaults = {
UIElement = 'CheckboxGrid', UIElement = 'CheckboxGrid',
checkedKey = 'checked', checkedKey = 'checked',
accelerators = { accelerators = {
space = 'grid_toggle', space = 'grid_toggle',
}, key_enter = 'grid_toggle',
},
} }
function UI.CheckboxGrid:drawRow(sb, row, focused, bg, fg) function UI.CheckboxGrid:drawRow(sb, row, focused, bg, fg)
local ind = focused and self.focusIndicator or ' ' local ind = focused and self.focusIndicator or ' '
@ -31,7 +32,7 @@ function UI.CheckboxGrid:drawRow(sb, row, focused, bg, fg)
end end
function UI.CheckboxGrid:eventHandler(event) function UI.CheckboxGrid:eventHandler(event)
if event.type == 'key_enter' and self.selected then if event.type == 'grid_toggle' and self.selected then
self.selected.checked = not self.selected.checked self.selected.checked = not self.selected.checked
self:draw() self:draw()
self:emit({ type = 'grid_check', checked = self.selected, element = self }) self:emit({ type = 'grid_check', checked = self.selected, element = self })