diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index f444c00..ead3543 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -1463,7 +1463,14 @@ function UI.Grid:update() end end - self.sorted = Util.keys(self.values) + self.sorted = { } + for k,v in pairs(self.values) do + if self:isRowValid(k, v) then + table.insert(self.sorted, k) + end + end + + --self.sorted = Util.keys(self.values) if order then table.sort(self.sorted, function(a,b) return order(self.values[a], self.values[b]) @@ -1545,6 +1552,12 @@ function UI.Grid:drawRows() end end +-- Non-intuitive: update must be called if the table was specified +-- in the shortcut definition (as this callback was not yet overridden) +function UI.Grid:isRowValid(--[[ key, value ]]) + return true +end + function UI.Grid:getRowTextColor(row, selected) if selected then if self.focused then @@ -2359,9 +2372,7 @@ function UI.Wizard:eventHandler(event) elseif event.type == 'previousView' then local currentView = Util.find(self.pages, 'enabled', true) local nextView = Util.find(self.pages, 'index', currentView.index - 1) - if self:isViewValid() then - currentView:emit({ type = 'enable_view', prev = nextView, current = currentView }) - end + currentView:emit({ type = 'enable_view', prev = nextView, current = currentView }) return true elseif event.type == 'wizard_complete' then diff --git a/sys/apis/util.lua b/sys/apis/util.lua index eb50f58..41a3f1c 100644 --- a/sys/apis/util.lua +++ b/sys/apis/util.lua @@ -356,6 +356,7 @@ function Util.readFile(fname) end function Util.writeFile(fname, data) + if not fname or not data then error('Util.writeFile: invalid parameters', 2) end local file = io.open(fname, "w") if not file then error('Unable to open ' .. fname, 2) @@ -489,7 +490,7 @@ function Util.insertString(str, istr, pos) end function Util.split(str, pattern) - if not str then error('Util:split: invalid parameters', 2) end + if not str then error('Util.split: Invalid parameters', 2) end pattern = pattern or "(.-)\n" local t = {} local function helper(line) table.insert(t, line) return "" end