How to interactively add items to a tree widget?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to interactively add items to a tree widget?

Rob Rothwell
This is probably a pretty newbie question, but can anyone point me towards creating some code to right click on a tree item and add a pop-up menu so I can prompt for some input and create a new child of that node?

I figured out how to change the contents of the tree in UITheme exampleBasicControls by creating a Dictionary with some child Dictionaries containing some objects, but now I seem to have a few challenges:

1.  The items are not being highlighted when I click on them (they aren't in the example either).
2.  I need a nudge in the right direction to capture the right click.
3.  If I do that and successfully add a new child to a node, I don't know how to tell the tree to refresh itself...

Thank you,

Rob

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: How to interactively add items to a tree widget?

Rob Rothwell
Benjamin,

Thanks for the encouragement!

> This is probably a pretty newbie question, but can anyone point me towards
> creating some code to right click on a tree item and add a pop-up menu so I
> can prompt for some input and create a new child of that node?
>

> I figured out how to change the contents of the tree in UITheme
> exampleBasicControls by creating a Dictionary with some child Dictionaries
> containing some objects, but now I seem to have a few challenges:
>
> 1.  The items are not being highlighted when I click on them (they aren't
> in
> the example either).
>

I have the same problem, so if you find how to make it works i'm listening
^^

 I think we can learn a lot from FileList, which uses the superclass of TreeListMorph (SimpleHierarchicalListMorph).  It properly highlights, and SimpleHierarchicalListMorph has a context menu as well.  It's all there, I am just not that good at reading Smalltalk code in general and morphic code specifically!

Also, SimpleHierarchicalListMorph submorphs example displays the same behavior we have noted, but you can see WHY since a proper selection method is not given during initialization.

I'm going to try to expand the submorphs example to have the functionality that the FileList drive volume pane does, and go from there...



> 2.  I need a nudge in the right direction to capture the right click.
>


Maybe you should rewrite the mouseDown: method and add a test like

   event yellowButtonPressed (or the button you want)
        ifTrue: [ "popup a menu" ]

We don't even need this for a popup menu...the functionality is built in, I think!
 



> 3.  If I do that and successfully add a new child to a node, I don't know
> how to tell the tree to refresh itself...
>
>
Send the message updateList to your MorphTreeMorph. If you have correctly
build your tree it works great ( but the highlighting doesn't work :s )

I was using TreeListMorph, one of the Polymorph controls, for which you seem to specifiy a #changeSelected: method...
 


Good luck

Benjamin

Thanks!

Rob

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project