|
Introduction
Containers Layouts Widgets
|
Widgets -> tree[PENDING: Document needs update.] You must be familiar with multi-dimensional arrays before working with trees. When creating trees, the first item of an array is always the "parent" category. Syntax: tree(@data [, properties]); ![]()
alias treedemo {
# Create the data first..
@treeData = array("Main Root",
array("Animals",
"Cow",
"Goat",
"Dog",
"Buffalo"),
array("Fruits",
"Nuts",
"Banana",
"Papaya",
"Oranges"),
array("Women",
"Jessica Alba",
"Keyra Augustina",
"Harumi Nemoto"),
"Last item with no child");
# Create the frame..
$tframe = frame("Tree Demo", 'center=1', 'size=500 400');
$tpanel = panel($tframe, 'layout=Border');
# Now the tree..
$mytreeSample = tree(@treeData, 'command=&myTreeListener', 'root=single');
addWidget($tpanel, $mytreeSample, 'area=CENTER');
show($tframe);
}
sub myTreeListener {
$var = getSelectedNode($mytreeSample);
echo("Selected item: $var");
echo("Parent: " . getParent($var));
}
Properties
Related functions
|