- I don't think you can set the treeview items withing the editor. So I would advise doing it manually.
To add a treeview item:
handle = addTreeviewItem( handleTreeview, handleParentitem, image, text [, insertAfterItem] )
Where you can leave out the insertAfterItem, and make image 0 when you haven't got an image list linked to your treeview.
- You can detect the toolbar being clicked using the constant in the gui.dba that comes with BlueGUI:
#constant TOOLBAR_CLICK 0x111
- I never have had any problems regarding the 3D canvas of DBP and BlueGUI except when using transparency with windows (It seemed to flicker on my screen).
- Treeviews' items can be found using
handle = selectedTreeviewItem(handleTreeview)
If you want to search which item was pressed, you have to compare the handle returned to the handle of each item you created.
I usually work with arrays to make it easier:
for example:
`Setup
sync on
set window on
randomize timer()
`These are the constants I use
#constant LEFTBUTTON_DOWN 513
#constant WINDOW_CLOSEBUTTON 524288
#constant ALIGN_ALL 1
`Create a treeview gadget and a new window
hWindow = createWindow(5, 5, 300, 500, "Overview", WINDOW_CLOSEBUTTON, 0, 0, 0)
hTreeview = createTreeview(5, 5, 100, 200, hWindow)
setGadgetAlign hTreeview, ALIGN_ALL
`Make two categories: Spheres and Cubes (root = 0 for parent item)
hCubes = addTreeviewItem(hTreeview, 0, 0, "Cubes")
hSpheres = addTreeviewItem(hTreeview, 0, 0, "Spheres")
`Make arrays that will contain the objects
type treeHandle
obj : `Refers to the object of the item
handle : `Refers to the handle of the item
endtype
dim hCubes(0) as treeHandle
dim hSpheres(0) as treeHandle
`--- Now add 5 spheres and cubes ---
for c = 1 to 5
`Firstly create a cube with random size and random position
make object cube c, 1 + rnd(10)
position object c, -50 + rnd(100), 0, -50 + rnd(100)
`Make a new treeview element after adding a new element to the Cube array
array insert at bottom hCubes()
hCubes(c).obj = c : `Store the object
hCubes(c).handle = addTreeViewItem(hTreeview, hCubes, 0, "Cube " + str$(c)) : `Create a treeview item and store handle
next c
for s = 1 to 5
`Firstly create a sphere with random size and random position
make object sphere 5 + s, 1 + rnd(10)
position object 5 + s, -50 + rnd(100), 0, -50 + rnd(100)
`Make new treeview element after adding a new element to the Sphere array
array insert at bottom hSpheres()
hSpheres(s).obj = 5 + s
hSpheres(s).handle = addTreeviewItem(hTreeview, hSpheres, 0, "Sphere " + str$(s))
next s
do
`Get event
getEvent
`If the leftmousebutton is clicked and the source is the treeview...
if eventType() = LEFTBUTTON_DOWN
if eventSource() = hTreeview
`There might be an object selected
`Retrieve the handle of the selected object
hSel = selectedTreeviewItem(hTreeview)
`Compart to the object
`Compare to cubes
for c = 1 to 5
if hSel = hCubes(c).handle : `When it's the same handle, this is the item
obj = hCubes(c).obj
point camera object position x(obj), object position y(obj), object position z(obj)
endif
next c
`Compare to spheres
for s = 1 to 5
if hSel = hSpheres(s).handle
obj = hSpheres(s).obj
point camera object position x(obj), object position y(obj), object position z(obj)
endif
next s
endif
endif
`Update camera position
position camera -100, 100, -100
sync
loop
I tried to put alot of remarks to understand it easier.
It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.