Fill listbox

From Vendetta Lua
Revision as of 09:37, 18 November 2010 by Otutytaqo (talk | contribs)
Jump to navigationJump to search

>== setup_cb == Definition:<br> setup_cb(int index, table itemlist, userdata subdlg) -> nil <br><br> Description: <br> Function initializes a list item in a list <br><br> Arguments:<br> index position within itemlist<br> itemlist table of iteminfo<br> subdialog an itemlist dialog <br><br>


Example

<source lang="lua"> -- a very crude item list with static data -- to be useful the action callback for c would handle highlighting and activation of items

-- build item list local items = {} -- title item table.insert(items, {desc="test"}) table.insert(items, {name="name1", desc="item1", quantity=2, price=10}) table.insert(items, {name="name2", desc="item2", price=11}) table.insert(items, {desc="test2"}) table.insert(items, {name="name3", desc="item3", price=13})

local c = iup.itemlisttemplate{control="yes", size="400x300"} local d = iup.dialog{c, topmost="yes"}

-- function called for each itemlist item local function setup_cb(index, item, subdlg) if item.price then subdlg:SetDesc(item.desc, false) subdlg:SetIcon("images/icon_addon_empty.png") else -- item is category item -- senter description subdlg:SetDesc(item.desc, true) subdlg:SetIcon() end

-- intialize some more fields subdlg:SetName(item.name) subdlg:SetQuantity(item.quantity) subdlg:SetPrice(item.price) end

d:show()

-- fill the list fill_listbox(c, items, 1, setup_cb, true, true) </source>