Ignore unhandled click events

This commit is contained in:
Gabriel Tofvesson 2024-10-08 16:21:14 +02:00
parent 6e95fe9007
commit 1b3cbfa2e8
3 changed files with 9 additions and 5 deletions

View File

@ -186,9 +186,13 @@ function Element:redraw()
end end
function Element:handleEvent(evt) function Element:handleEvent(evt)
if Event.isClickEvent(evt) and self.onClick ~= nil and Event.containsClick(self, evt, 0, 0) then if Event.isClickEvent(evt) and Event.containsClick(self, evt, 0, 0) then
local x, y, source = Event.getClickParams(evt) if self.onClick ~= nil then
return not not self.onClick(self, x, y, source) local x, y, source = Event.getClickParams(evt)
return not not self.onClick(self, x, y, source)
else
return false
end
end end
return false return false
end end

View File

@ -90,7 +90,6 @@ function Padding:handleEvent(evt)
else else
return self.element:handleEvent(evt) return self.element:handleEvent(evt)
end end
return false
end end
function Padding:_reload() function Padding:_reload()

View File

@ -3,6 +3,7 @@ local ItemGroup = require("storage.itemgroup")
local Storage = require("storage") local Storage = require("storage")
local Text = require("gfx.text") local Text = require("gfx.text")
local List = require("gfx.list") local List = require("gfx.list")
local Event = require("gfx.event")
local Padding = require("gfx.padding") local Padding = require("gfx.padding")
@ -147,7 +148,7 @@ local function renderDefault(state, rootElement)
end end
end end
if not handled then if not handled and not Event.isClickEvent(event) then
os.queueEvent(table.unpack(event)) os.queueEvent(table.unpack(event))
end end