How to lay a morph down automatically

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

How to lay a morph down automatically

Mike O'Brien-5
        Newly opened morphs seem to arrive in "picked-up" mode,
attached to the "hand" (cursor).  You left-click to drop them.

        I went looking for the code that executes when you left
click on a picked-up morph but couldn't find it.

        If I wanted to create a morph programmatically and have
it start life already laid down somewhere, how would I do that?
I'm presuming that the same check would get done as to whether it
were to embed itself in whatever it was laid down on, or just
sit there.  Of course this might wind up embedding it in whatever
the mouse cursor happened to be sitting on at the moment, which
would be bad news, since in this case the mouse and the morph
wouldn't be near each other.

        Thanks!

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

Re: How to lay a morph down automatically

cdavidshaffer
Mike O'Brien wrote:

> Newly opened morphs seem to arrive in "picked-up" mode,
>attached to the "hand" (cursor).  You left-click to drop them.
>
> I went looking for the code that executes when you left
>click on a picked-up morph but couldn't find it.
>
> If I wanted to create a morph programmatically and have
>it start life already laid down somewhere, how would I do that?
>I'm presuming that the same check would get done as to whether it
>were to embed itself in whatever it was laid down on, or just
>sit there.  Of course this might wind up embedding it in whatever
>the mouse cursor happened to be sitting on at the moment, which
>would be bad news, since in this case the mouse and the morph
>wouldn't be near each other.
>
> Thanks!
>
>Mike O'Brien
>______________________________________________
>  
>
Mike,

Is this what you mean?

HeadMorph new openInWorld

as opposed to

HeadMorph new openInHand

Additional you can position them:

hm := HeadMorph new openInWorld.
hm position: 400@300.

Hope that helps...

David



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

Re: How to lay a morph down automatically

Mike O'Brien-5
> hm := HeadMorph new openInWorld.
> hm position: 400@300.

        That blows up because "hm" turns out to be some sort
of BlockContext, not a HeadMorph, but it gave me the right
idea, thanks!

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

Re: How to lay a morph down automatically

cdavidshaffer
Mike O'Brien wrote:

>>hm := HeadMorph new openInWorld.
>>hm position: 400@300.
>>    
>>
>
> That blows up because "hm" turns out to be some sort
>of BlockContext, not a HeadMorph, but it gave me the right
>idea, thanks!
>
>Mike O'Brien
>_______________________________________________
>Beginners mailing list
>[hidden email]
>http://lists.squeakfoundation.org/mailman/listinfo/beginners
>  
>
I tried that exact code under Squeak 3.7, 3.8 and 3.9beta-7041 and it
worked as expected in all of them.  I don't understand why you'd get a
BlockContext back from #openInWorld.  Are you sure that you typed it
correctly?  Maybe you're running something which redefines #openInWorld
(Croquet?, Tweak?)?

David

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

Re: How to lay a morph down automatically

Mike O'Brien-5
> I tried that exact code under Squeak 3.7, 3.8 and 3.9beta-7041 and it
> worked as expected in all of them.

        I don't understand either.  I tried it again and this
time it worked.  I can only infer that hitting ESC and then doIt
from the context menu picked up either too little or too much text.

        Last time I used Smalltalk was in the ST80 days.  Back
then, hitting ESC highlighted the text before you picked doIt.
These days, it doesn't highlight till after the doIt, so you're
slightly in the dark as to what you're actually executing.
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners