diff --git a/gfx/element.lua b/gfx/element.lua index 6371e2b..658f3e6 100644 --- a/gfx/element.lua +++ b/gfx/element.lua @@ -13,7 +13,8 @@ local Element = { visible = true, dirty = true, id = "", - onClick = nil + onClick = nil, + onKey = nil } Element.__index = Element @@ -203,6 +204,9 @@ function Element:handleEvent(evt) if Event.isClickEvent(evt) and Event.containsClick(self, evt) and self.onClick ~= nil then local x, y, source = Event.getClickParams(evt) return not not self.onClick(self, x, y, source) + elseif Event.isKeyEvent(evt) and self.onKey ~= nil then + local key, held = Key.getKeyParams(evt) + return not not self.onKey(self, key, held) end return false end