diff --git a/gfx/element.lua b/gfx/element.lua index 658f3e6..756bef3 100644 --- a/gfx/element.lua +++ b/gfx/element.lua @@ -14,7 +14,9 @@ local Element = { dirty = true, id = "", onClick = nil, - onKey = nil + onKey = nil, + onChar = nil, + onEvent = nil } Element.__index = Element @@ -205,10 +207,13 @@ function Element:handleEvent(evt) 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) + local key, held = Event.getKeyParams(evt) return not not self.onKey(self, key, held) + elseif Event.isCharEvent(evt) and self.onChar ~= nil then + local keyChar = Event.getCharValue(evt) + return not not self.onChar(self, keyChar) end - return false + return self.onEvent ~= nil and self.onEvent(self, evt) end function Element:setOnClick(onClick)