Difference between revisions of "Fill listbox"
From Vendetta Lua
Line 1: | Line 1: | ||
− | + | == setup_cb == | |
− | '''Definition:''' | + | '''Definition:'''<br> |
− | setup_cb(int index, table itemlist, userdata subdlg) - | + | setup_cb(int index, table itemlist, userdata subdlg) -> nil |
− | + | <br><br> | |
− | '''Description:''' | + | '''Description:''' <br> |
Function initializes a list item in a list | Function initializes a list item in a list | ||
− | + | <br><br> | |
− | '''Arguments:''' | + | '''Arguments:'''<br> |
− | '''index''' position within itemlist | + | '''index''' position within itemlist<br> |
− | '''itemlist''' table of [[iteminfo]] | + | '''itemlist''' table of [[iteminfo]]<br> |
'''subdialog''' an itemlist dialog | '''subdialog''' an itemlist dialog | ||
− | + | <br><br> | |
− | + | ||
− | + | ||
− | < | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | < | + | |
== Example == | == Example == |
Latest revision as of 18:54, 20 November 2010
setup_cb
Definition:
setup_cb(int index, table itemlist, userdata subdlg) -> nil
Description:
Function initializes a list item in a list
Arguments:
index position within itemlist
itemlist table of iteminfo
subdialog an itemlist dialog
Example
-- 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)