List:onContext(ListItem) event
This event is fired when a right-click occured on the List.
Return value
This event returns no value.Example
local ui = require "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