It's even worse. It seems that subitems with children are appended after leaves:
prog3 = {
PROG = {
'x := 27',
'y := x + 100',
RED = {
'x := x * 4',
PINK = {
BLUE = {
'ch ! 4',
YELLOW = { '1', '2', '3' },
'ch ? x',
GREEN = { '5', '6', '7' }
}
},
'y := y + 1',
}
}
}
local tree = ui.Tree(win, prog3, 0, 0, 320, 400)
----
dumped:
PROG
x := 27
y := x + 100
RED
x := x * 4
y := y + 1
PINK
BLUE
ch ! 4
ch ? x
GREEN
5
6
7
YELLOW
1
2
3
New info: it seems a problem with the constructor only, adding nodes manually after creating the Tree looks better
Another point: how to force the selection of a specific TreeItem in the tree ?