Feature TreeGadget items

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
alban
New User
New User
Posts: 5
Joined: Tue May 20, 2008 7:42 pm

Feature TreeGadget items

Post by alban »

Feature request for the value from AddGadgetItem to return the item value from a tree.

value = AddGadgetItem(#myTree, -1, Text$, 0, CurrentSublevel)

It would be nice if the value returned was the item number of the item just created.
Alternatively some other way of fetching the value of the last item created would be really useful.

Also a command like item=ParentItem( item) would be nice.
This would allow us to work our way back up a tree without using API calls.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Feature TreeGadget items

Post by freak »

alban wrote:Feature request for the value from AddGadgetItem to return the item value from a tree.

value = AddGadgetItem(#myTree, -1, Text$, 0, CurrentSublevel)

It would be nice if the value returned was the item number of the item just created.
Alternatively some other way of fetching the value of the last item created would be really useful.
If you pass -1 as position in the 2nd parameter, the new item will be at index CountGadgetItems(#myTree)-1,
and if you pass another position, the new item will be at the passed index.
alban wrote:Also a command like item=ParentItem( item) would be nice.
This would allow us to work our way back up a tree without using API calls.
Just examine the items sublevel like this:

Code: Select all

Procedure GetParent(tree, item)
  level  = GetGadgetItemAttribute(tree, item, #PB_Tree_Sublevel)
  parent = item-1
  While parent >= 0 And level <= GetGadgetItemAttribute(tree, parent, #PB_Tree_Sublevel)
    parent - 1
  Wend
  ProcedureReturn parent
EndProcedure
When walking the list backwards, the first item with a sublevel lower than the current one is always its parent.
quidquid Latine dictum sit altum videtur
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It would be nice if other List/Tree functions than AddGadgetItem() also accepted -1.
Post Reply