[SimpleHierarchaelListMorph]

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

[SimpleHierarchaelListMorph]

Steve Moffitt
Hi -- I sent this to beginners list but didn't get a reply so will  
try here.

Hi all -- and thanks in advance. I'm finding  
SimpleHierarchaelListMorph not so simple. I can add items to the list  
easily enough if code that follows is anywhere close to being right,  
but how would I add a subitem programactically to item 1.

x := SimpleHierarchicalListMorph
                        on: [ OrderedCollection with:  (ListItemWrapper with: 'item 1')  ]
                        list: #value
                        selected: nil
                        changeSelected: nil
                        menu: nil
                        keystroke: nil.

y := x  getList.
y add: (ListItemWrapper with: 'item 2').
x list: y.
x openInWorld

I've looked at the examples and still not getting it.
Again thanks,
Steve


Reply | Threaded
Open this post in threaded view
|

Re: [SimpleHierarchaelListMorph]

Hernan Tylim-2
Hi Steve,

ListItemWrapper was meant to be subclassed rather than used directly, and as you said its not simple at all.

Answering your question what you need to do is to have your own ListItemWrapper class and make it answer to #contents with an OrderedCollection of your item subitem´s ListItemWrapper instances.

For a complete example of HierarchicalListMorph you can look how I did it in Jacaranda (look for it in Squeakmap, and in the DiagramOrganization classes).

hope it helps.

p.s. if you wish you can forward this mail to the beginners list. I am not subscribed.

Regards,
Hernán


On 5/8/06, Steve Moffitt <[hidden email]> wrote:
Hi -- I sent this to beginners list but didn't get a reply so will
try here.

Hi all -- and thanks in advance. I'm finding
SimpleHierarchaelListMorph not so simple. I can add items to the list
easily enough if code that follows is anywhere close to being right,
but how would I add a subitem programactically to item 1.

x :=            SimpleHierarchicalListMorph
                        on: [ OrderedCollection with:  (ListItemWrapper with: 'item 1')  ]
                        list: #value
                        selected: nil
                        changeSelected: nil
                        menu: nil
                        keystroke: nil.

y := x  getList.
y add: (ListItemWrapper with: 'item 2').
x list: y.
x openInWorld

I've looked at the examples and still not getting it.
Again thanks,
Steve





--
Saludos,
Hernán