This event will not be fired if the clicked MenuItem already has an onClick() event handler, that will be called instead.
Menu:onClick(item) event
This event is fired when the user has clicked on a Menu item.
Parameters
item
The MenuItem that have been clicked.
Return value
The event returns no value.Example
local ui = require "ui"
-- create a simple Window
local win = ui.Window("Menu:onClick() sample", 316, 246)
win.menu = ui.Menu()
-- insert a new MenuItem "File" with a submenu
local File = win.menu:insert(1, "File", ui.Menu("New", "Open", "Save", "Quit"))
-- set a File submenu onClick() event handler
function File.submenu:onClick(item)
if item.index == self.count then
win.visible = false
else
ui.info("You have selected '"..item.text.."'")
end
end
-- shows the Window
win:show()
-- update user interface
repeat
ui.update()
until not win.visible