Re: Tree widget woes [message #37391 is a reply to message #37281] |
Mon, 15 December 2003 06:49   |
robert.dimeo
Messages: 42 Registered: November 2001
|
Member |
|
|
robert.dimeo@nist.gov (Rob Dimeo) wrote in message news:<cb539436.0312120837.5f2aa843@posting.google.com>...
> then press the button labeled ADD_FOLDER. What I want to happen is
> for a whole new hierarchy of folders to appear at the root level. It
> actually appears under the leaf that was selected. Now if you run the
> program with the keyword MULT=0 you get the desired behavior.
> Unfortunately I want to be able to select multiple files AND be able
> to put in the new folder hierarchy. Can I have my cake and eat it
> too? Any help would be greatly appreciated.
>
So I guess I'll reply to my own posting with a workaround (the silence
was deafening...anyone else out there using the tree widgets?). The
code below shows how I implemented the workaround. The idea is to add
a folder (node) at the root level and make all additional folders
children of that one. I would rather not have to put in the root
folder but it's the only fix that I could come up with.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro tt_add_folder,event
; Get the widget id of the root node...
root = widget_info(event.top,find_by_uname = 'ROOT')
; and make the additional folders and leaves children of the root.
group = widget_tree(root,value = 'Data Group',/folder,$
/expanded)
leaf1 = widget_tree(group, value = 'Data')
leaf2 = widget_tree(group, value = 'Data')
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro tt_event,event
uname = widget_info(event.id,/uname)
case uname of
'QUIT': widget_control,event.top,/destroy
'ADD_FOLDER': tt_add_folder,event
else:
endcase
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro tree_widget_test,mult = mult
if n_elements(mult) eq 0 then mult = 0
register_name = 'tw_test'
tlb = widget_base(title = 'Tree Widget Test',/col,/tlb_frame_attr)
tree_base = widget_base(tlb,/col)
file_tree = widget_tree(tree_base,multiple = mult,uname = 'FILE_TREE')
; Define the root node...
root = widget_tree(file_tree,value = 'Root',/folder,/expanded, $
uname = 'ROOT')
; and make all the rest children of that node
group = widget_tree(root,value = 'Data Group',/folder,$
/expanded)
leaf1 = widget_tree(group, value = 'Data')
leaf2 = widget_tree(group, value = 'Data')
void = widget_button(tlb,value = 'ADD FOLDER',uname = 'ADD_FOLDER')
void = widget_button(tlb,value = 'QUIT',uname = 'QUIT')
widget_control,tlb,/realize
xmanager,register_name,tlb,/no_block,event_handler = 'tt_event'
end
|
|
|