mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
da65ac8b02
* Iterate over varargs directly via select if possible * Use table.pack otherwise (https://github.com/koreader/koreader-base/pull/1535). * This allows us to simplify a few Logger calls, as logger now handles nil values.
41 lines
858 B
Lua
41 lines
858 B
Lua
--[[--
|
|
Events are messages that are passed through the widget tree.
|
|
|
|
Events need a "name" attribute as minimal data.
|
|
|
|
To see how event propagation works and how to make
|
|
widgets event-aware see the implementation in @{ui.widget.container.widgetcontainer}.
|
|
|
|
A detailed guide to events can be found in @{Events.md|the event programmer's guide}.
|
|
]]
|
|
|
|
--[[--
|
|
@field handler name for the handler method: `"on"..Event.name`
|
|
@field args array of arguments for the event
|
|
@table Event
|
|
]]
|
|
local Event = {}
|
|
|
|
--[[--
|
|
Creates a new event.
|
|
|
|
@string name
|
|
@tparam[opt] ... arguments for the event
|
|
@treturn Event
|
|
|
|
@usage
|
|
local Event = require("ui/event")
|
|
Event:new("GotoPage", 1)
|
|
]]
|
|
function Event:new(name, ...)
|
|
local o = {
|
|
handler = "on"..name,
|
|
args = table.pack(...),
|
|
}
|
|
setmetatable(o, self)
|
|
self.__index = self
|
|
return o
|
|
end
|
|
|
|
return Event
|