Morphic - how to make a submorph not visible outside his owner ?

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

Morphic - how to make a submorph not visible outside his owner ?

patrick dudjalija
Hi everyone !

I'm playing around with horizontal scrolling of a submorph into a morph.
Let's take a simple horizontal scrolling to the left.
When the submorph is getting out of the left side of the  morph, it should reappear to the right side of the morph.
The problem is that during the "transition" the submorph is still visible outside of the morph.
So, I'm searching for a solution for the submorph not being visible outside the bounds of it's owner.

To visualize the problem, see code below.
(for an obscure reason, the transcript window must be opened, but that's not the point).

Thanks a lot for your help !!!!

Here is the sample code (don't forget to open the transcript window):



|m1 m2|

m1:=Morph new.
m1 extent:800@600.
m1 color:Color blue.
m1 center: Display center.
m1 openInWorld.

m2:=Morph new.
m2 extent:200@200.
m2 color:Color red.

m1 addMorph: m2.
m2 center: m1 center.

1 to:200 do:[:el|
|pos|
(Duration seconds:0.01) asDelay wait.
pos:=(m2 position x -5)@(m2 position y).
((pos x + m2 width) >= (m1 position x)) ifFalse:[
pos:=((m1 position x + m1 width)@ m2 position y).
].
Transcript show: (pos asString);cr.
m2 position:pos.
].


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

Re: Morphic - how to make a submorph not visible outside his owner ?

dcorking
Patrick, Is clipSubmorphs what you want?

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

Re: Morphic - how to make a submorph not visible outside his owner ?

dcorking
I should be more specific. Try

m1 clipSubmorphs: true.

Hope that helps. David

p.s. I think your do loop pre-empts the Morphic UI loop.
Have you read John Maloney's tutorial on the step method?
http://stephane.ducasse.free.fr/FreeBooks/CollectiveNBlueBook/morphic.final.pdf
In the meantime, you could switch your Transcript hack for this hack :)
  m1 refreshWorld.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners