List:onContext(ListItem)event
Event fired when the user has right clicked on an item in the List.
Parameters
ListItem
The right clicked ListItem
Return value
This event returns no value.Example
--! luart-extensions
import ui
-- creates a simple window
local win = ui.Window("List:onContext() event sample", 320, 260)
local list = ui.List(win, {"Item1", "Item2", "Item3"}, 120, 60)
-- List:onContext event
function list:onContext(item)
-- show popup menu if onContext event occured on an item
if item ~= nil then
local menu = ui.Menu("Delete ListItem")
menu.items[1].onClick = function (self)
item:remove()
end
win:popup(menu)
end
end
win:show()
-- update window
while win.visible do
ui.update()
end