|
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
1. Dynamically add a branch to a TREE #10770 Posted by: mestrini 2007-06-27 00:39:58 Last edited by: Jeff Glatt 2007-07-03 08:30:35 (Total edited 1 time) |
How can i dynamically add a 'branch' (child or parent) to a TREE control? Placing it at a specific branch/level? Without wiping out the current contents of the tree? |
2. #10789 Posted by: Jeff Glatt 2007-06-27 15:34:54 Last edited by: Jeff Glatt 2007-06-27 15:40:26 (Total edited 2 times) |
You use GuiAddCtlText().
You can add a new root parent node (at the end of the tree) with GuiAddCtlText(), by passing a third arg. But there isn't a way (right now) to add a new child to an existing parent, nor place a new root parent in a position other than the end.
The only way to do this is to reinitialize your stem variable describing the tree, and then call GuiAddCtlText().
mytreeitems.1 = 'Parent 1'
mytreeitems.2 = 'Parent 2'
mytreeitems.3 = 'Parent 3'
mytreeitems.3.1 = 'Child 1'
mytreeitems.3.2 = 'Child 2'
mytreeitems.3.2.1 = 'One more'
DROP mytree
guiaddctltext("MyTree", "MyTreeItems")
mytreeitems.2.1 = 'Child 1'
guiaddctltext("MyTree", "MyTreeItems") |
3. #10793 Posted by: mestrini 2007-06-27 16:45:18 Last edited by: Jeff Glatt 2007-07-03 08:37:41 (Total edited 3 times) |
It's a shame that we can't add a child to a desired location in a tree. I could really use that feature; pls consider this a "REQ:" ;) |
4. Out of interest ... #10830 Posted by: misi01 2007-06-28 18:47:05 Last edited by: Jeff Glatt 2007-07-03 08:39:24 (Total edited 2 times) |
I looked over your original script. You use GuiImageList(). Where did you get that from?
Re, your comment about pushbutton 2, isn't the following what you're after instead ?h=1; branch_check="dummy_value"
DO FOREVER
IF EXISTS('MyTreeItems.2.'||h) = 0 THEN LEAVE
h=h+1
END Michael |
5. THAT'S IT! #10831 Posted by: mestrini 2007-06-28 19:43:15 Last edited by: Jeff Glatt 2007-07-03 08:33:37 (Total edited 2 times) |
Thanks a lot michael! That did the trick.
The GuiImageList() is demonstrated in Jeff's TREE example script at his site. |
6. deleted items appear again! #10832 |
Sorry to append this here but don't think this issue requires a dedicated thread.
Just add a PUSH button named 'del_button' to the test script above and append following code at the endwm_click_del_button:
guigetctlvalue('MyTree')
guiremovectltext("MyTree", "")
RETURN You'll see that after deleting items (any of your choice) and adding new ones it will make the original (and others added at runtime) appear again. |
7. A thought ... #10833 |
without testing this, I had a problem that boiled down to the fact that Jeff said/suggested I DROP the variable containing the items I wanted to update (in my case, it was a listbox).
If you muck around with that (droppig the variable(s)), does it help ? |
8. Re:A thought ... #10843 Posted by: mestrini 2007-06-29 00:34:13 Last edited by: Jeff Glatt 2007-07-03 08:32:33 (Total edited 2 times) |
It does work!! After some trial and error, I figured out how to have items not appear again. It should be something like this:wm_click_del_button:
guigetctlvalue('MyTree')
guiremovectltext("MyTree", "")
DROP mytree_items.mytree
RETURN |
9. #10852 |
Yeah, if you're totally changing the configuration of the TREE, you should first DROP the variable to clear out the old definition. I didn't do that in my example because I was just adding another child to an existing configuration. |
10. #10859 |
Ok, in regards to that "crash". It actually wasn't crashing. It was simply causing the script to hang in the call to GuiGetMsg() (and never return). This is fixed in the latest REXX GUI.
The problem is that you were getting the NOVALUE condition raised inside of a REXX GUI event handler (that actually gets called within your own call GuiGetMsg). Because you weren't trapping NOVALUE any place in your script, this causes REXX GUI to close all your windows inside of GuiGetMsg, but unfortunately doesn't return. I've modified this so that it now does.
But of course, the initial problem is that you're using the VALUE function incorrectly. The first arg is the name of the variable. You're not quoting it, so what happens is you're trying to pass the value of that variable. It doesn't have a value so NOVALUE is raised. If you called VALUE with the first arg the way Mike does it with EXISTS, it would have worked. |
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |