diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index 3dc03c0..4162f3a 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -3001,22 +3001,26 @@ function UI.Chooser:eventHandler(event) if event.type == 'key' then if event.key == 'right' or event.key == 'space' then local _,k = Util.find(self.choices, 'value', self.value) + local choice if k and k < #self.choices then - self.value = self.choices[k+1].value + choice = self.choices[k+1] else - self.value = self.choices[1].value + choice = self.choices[1] end - self:emit({ type = 'choice_change', value = self.value }) + self.value = choice.value + self:emit({ type = 'choice_change', value = self.value, element = self, choice = choice }) self:draw() return true elseif event.key == 'left' then local _,k = Util.find(self.choices, 'value', self.value) + local choice if k and k > 1 then - self.value = self.choices[k-1].value + choice = self.choices[k-1] else - self.value = self.choices[#self.choices].value + choice = self.choices[#self.choices] end - self:emit({ type = 'choice_change', value = self.value }) + self.value = choice.value + self:emit({ type = 'choice_change', value = self.value, element = self, choice = choice }) self:draw() return true end diff --git a/sys/apps/Overview.lua b/sys/apps/Overview.lua index fb0bbc0..14740fc 100644 --- a/sys/apps/Overview.lua +++ b/sys/apps/Overview.lua @@ -37,12 +37,12 @@ local extSupport = Util.getVersion() >= 1.76 local function loadApplications() local requirements = { - turtle = function() return turtle end, - advancedTurtle = function() return turtle and term.isColor() end, - advanced = function() return term.isColor() end, - pocket = function() return pocket end, - advancedPocket = function() return pocket and term.isColor() end, - advancedComputer = function() return not turtle and not pocket and term.isColor() end, + turtle = not not turtle, + advancedTurtle = turtle and term.isColor(), + advanced = term.isColor(), + pocket = not not pocket, + advancedPocket = pocket and term.isColor(), + advancedComputer = not turtle and not pocket and term.isColor(), } applications = Util.readTable('sys/etc/app.db') @@ -76,10 +76,7 @@ local function loadApplications() end if a.requires then - local fn = requirements[a.requires] - if fn and not fn() then - return false - end + return requirements[a.requires] end return true -- Util.startsWith(a.run, 'http') or shell.resolveProgram(a.run)