ListItem.index read/write

Get or set the item position, a number starting from 1 and increase until the total count of items in the List.

Example

local ui = require "ui" -- create a simple Window local win = ui.Window("ListItem.index sample", 320, 100) local list = ui.List(win, {"LuaRT", "is", "fun !"}, 110, 60) local inc_btn = ui.Button(win, "Increase item position !", 15, 10) local dec_btn = ui.Button(win, "Decrease item position !", inc_btn.x+150, inc_btn.y) inc_btn.delta = 1 dec_btn.delta = -1 list.selected = list.items[1] function inc_btn:onClick() local item = list.selected or false if (item) then item.index = item.index + self.delta end end dec_btn.onClick = inc_btn.onClick -- shows the Window win:show() -- update user interface repeat ui.update() until not win.visible