MenuItem.index read/write
Get or set the MenuItem position, a number starting from 1 and increasing until the total count of items in the Menu.
Example
local ui = require "ui"
-- create a simple Window
local win = ui.Window("MenuItem.index sample", 316, 246)
local button = ui.Button(win, "Move 'File' position", 100, 86)
win.menu = ui.Menu("File", "Edit", "View", "Options")
local File = win.menu.items[1]
File.submenu = ui.Menu("New", "Open", "Save", "Quit")
local direction = 1
function button:onClick()
if File.index == win.menu.count then
direction = -1
elseif File.index == 1 then
direction = 1
end
File.index = File.index+direction
end
-- shows the Window
win:show()
-- update user interface
repeat
ui.update()
until not win.visible