2016-12-05 00:41:01 +00:00
--[[--
2019-08-30 13:06:30 +00:00
Events are messages that are passed through the widget tree .
2012-04-22 19:29:48 +00:00
Events need a " name " attribute as minimal data .
2019-08-30 13:06:30 +00:00
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 } .
2019-08-30 13:06:30 +00:00
A detailed guide to events can be found in @ { Events.md | the event programmer ' s guide}.
2016-12-05 00:41:01 +00:00
] ]
--[[--
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
--[[--
2019-08-30 13:06:30 +00:00
Creates a new event .
2016-12-05 00:41:01 +00:00
@ 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 ,
Revamp flash_ui handling, once more, with feeling ;) (#7262)
* Simplify flash_ui handling (by handling the unhighlight pre-callback, c.f., #7262 for more details).
* UIManager: Handle translucent window-level widgets (and those wrapped in a translucent MovableContainer) properly in setDirty directly, making sure what's *underneath* them gets repainted to avoid alpha layering glitches. (This was previously handled via localized hacks).
* Update UIManager's documentation, and format it properly for ldoc parsing, making the HTML docs more useful.
* ReaderView: Reinitialize the various page areas when opening a new document, to prevent poisoning from the previous document.
* Event: Handle nils in an event's arguments.
* CheckButton/RadioButton: Switch to simple inversion to handle highlighting
* CheckButton: Make the highlight span the inner frame's width, instead of just the text's width, if possible.
* AlphaContainer: Fix & simplify, given the UIManager alpha handling.
* MovableContainer: When translucent, cache the canvas bb used for composition.
* Avoid spurious refreshes in a few widgets using various dummy *TextWidgets in order to first compute a text height.
* KeyValuePage: Avoid floats in size computations.
2021-02-20 17:22:48 +00:00
-- Minor trickery to handle nils, c.f., http://lua-users.org/wiki/VarargTheSecondClassCitizen
--- @fixme: Move to table.pack() (which stores the count in the field `n`) here & table.unpack() in @{ui.widget.eventlistener|EventListener} once we build LuaJIT w/ 5.2 compat.
argc = select ( ' # ' , ... ) ,
2014-03-13 13:52:43 +00:00
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