This is what i use for doing the same
Code:
Class ListViewItem
(
var sel: Boolean = false; var value: String; override function toString(): String ( "(if (sel)"#"else"-") (value) )
)
class ListViewCell extends listcell
(
/ / Create the share of the cell
CheckBox def st = (); Label def text = ();
/ / Create the nd
init
(
nd = HBox
(
content: [ st, text ]
)
)
/ / Init recycled gold created nodes: the update When controls st of the item is changed
itemWatcher var = item bd we replace
(
if (item! = null) / / Called with null Often, For Some Reason, can Be worth skipping thesis
(
st.sel = (item as ListViewItem).sel, text.text = item.toString();
)
)
/ / Watch the checkbox st to persist it in the item
var bd = itemStateWatcher st.sel we replace
(
(item as ListViewItem).sel = itemStateWatcher; text.text = item.toString(); onUpdate(); / / Update view (text)
)
)
function gtcl(): listcell
(
ListViewCell ()
)
var listStuff: ListView listview =
(
layoutX: 50, layoutY: 50
layoutInfo: LayoutInfo ( height: 300, width: 200 )
cellFactory: gtcl items: for (i in [ 1 .. 200 ]) ListViewItem ( value: "Item 03d% (i) )
)
/ * var selectedItemWatcher: Object = (bd listStuff.selectedItem we replace SIW def = selectedItemWatcher have ListViewItem; siw.sel = not siw.sel;) * /
var sc: sc; Stage
(
title: "New Tests ListView"
sc: sc = sc
(
width: 500
height: 500
fill: Color.Goldenrod
content: listStuff
)
)
Bookmarks