a simple Morph

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

a simple Morph

Stephan Janosch-2
Hi there!

I have some difficulties to create a morph, which shows me simply all
elements of an array inside that morph.

my morph has an instance var called myArray.

now the morph should simply show the contents of myArray.

and here my confusion start. I don't want to reprogram
PluggableListMorph. But I don't get this thing to use myArray. I guess
PluggableListMorph want's to have a model. Or?

So I should the MVC stuff, or?

I did some morphic tutorials, but none of these showed me, how to build
a more complex morph. There are rectangles, drag and drop and so on.

But there is nothing like: here is a collection, now show me all
elements of that collection inside a morph (as a list).

In my understanding, I would build a classic MVC-triple. But as i
understood Morphic, there is no need for classic MVC anymore. So I am
badly confused.

My realisation so far:

BorderedMorph subclass: #MenschMorph
        instanceVariableNames: 'liste'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'UserObjects'

initialize
        | c m|
        super initialize.
        self extent: 50@50.
        self position: 50@50.
        self color: Color white.
        self liste: #('name' 'alter' 'huhu').
       
        c  := 1.
        liste  do:
                [:each |
                        m := TextMorph new openInWorld.
                        m position: self position + (1@c*10).
                        c:= c+1.
                        self addMorph: m.
                ].

Now i would write some manipulation stuff for 'liste'. I would delete
all the TextMorphs and simply redraw them, but with my manipulated list
as new 'input'.

And that feels damn wrong to me. How to proceed?

My goal should be a Morph, which shows me simply the contens of a list.
The Morph should update itself, when i manipulate the list. Classic MVC
for me. Am I right?

So long,
Stephan
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: a simple Morph

Tapple Gao
On Thu, Aug 07, 2008 at 03:13:40PM +0200, Stephan Janosch wrote:
> But there is nothing like: here is a collection, now show me all
> elements of that collection inside a morph (as a list).

This works for me:

myArray explore
myArray inspect

> My goal should be a Morph, which shows me simply the contens of a list.
> The Morph should update itself, when i manipulate the list. Classic MVC
> for me. Am I right?

well, if you want auto-updating, you will need one of two things:

- somebody that polls the collection, or
- a collection that sends out events when it changes

The first is what the Inspector tool does

The second is what Etoys and Tweak do. Etoys does not have a
generic event-sending collection, but Tweak does: CCollection

A few things in squeak actually do send out notifications on
change, like the Class heiarchy, but not in a very generic way.
See SystemChangeNotifier and references to it

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: a simple Morph

Herbert König
In reply to this post by Stephan Janosch-2
Hello Stephan,

Thursday, August 7, 2008, 3:13:40 PM, you wrote:

SJ> and here my confusion start. I don't want to reprogram
SJ> PluggableListMorph. But I don't get this thing to use myArray. I guess
SJ> PluggableListMorph want's to have a model. Or?

yes


SJ> My goal should be a Morph, which shows me simply the contens of a list.
SJ> The Morph should update itself, when i manipulate the list. Classic MVC
SJ> for me. Am I right?

http://wiki.squeak.org/squeak/2962 has pluggableListMorphDemo.pr which
shows you how to use your array as model for the list.


--
Cheers,

Herbert  

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: a simple Morph

Stephan Janosch-2
Thanks Herbert ( and Matthew )

> http://wiki.squeak.org/squeak/2962 has pluggableListMorphDemo.pr which
> shows you how to use your array as model for the list.

I'll have a look at that.

And I'll post code, which helps to realize my project.

so long,
Stephan
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners