2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/frontend/ui/event.lua

39 lines
767 B
Lua
Raw Normal View History

2016-12-05 00:41:01 +00:00
--[[--
2012-04-22 19:29:48 +00:00
Events are messages that are passed through the widget tree
Events need a "name" attribute as minimal data.
In order to see how event propagation works and how to make
2016-12-05 00:41:01 +00:00
widgets event-aware see the implementation in @{ui.widget.container.widgetcontainer}.
]]
--[[--
2016-12-11 03:08:31 +00:00
@field handler name for the handler method: `"on"..Event.name`
2016-12-05 00:41:01 +00:00
@field args array of arguments for the event
@table Event
2012-04-22 19:29:48 +00:00
]]
2013-10-18 20:38:07 +00:00
local Event = {}
2012-04-22 19:29:48 +00:00
2016-12-05 00:41:01 +00:00
--[[--
Create a new event.
@string name
@tparam[opt] ... arguments for the event
@treturn Event
@usage
local Event = require("ui/event")
Event:new("GotoPage", 1)
]]
2012-04-22 19:29:48 +00:00
function Event:new(name, ...)
2014-03-13 13:52:43 +00:00
local o = {
handler = "on"..name,
args = {...}
}
setmetatable(o, self)
self.__index = self
return o
2012-04-22 19:29:48 +00:00
end
2013-10-18 20:38:07 +00:00
return Event