How do I wait for HandMorph>>openInHand to complete?

Ned Konz ned at bike-nomad.com
Sun Aug 22 13:38:23 UTC 2004


On Sunday 22 August 2004 12:44 am, Trygve Reenskaug wrote:

> I have the following simple code in a PasteUpMorph subclass:
>
>     symbol := MyMorph new.                 " create "
>     symbol openInHand.                     " place "
>     (self submorphs includes: symbol true) " use "
>        ifFalse: [self error]
>
> I get the error because HandMorph>>openInHand digresses into the jungle on
> a separate thread to make me place the symbol.

There should be only ONE THREAD in Morphic. If you need multiple threads, none 
of the threads that is not THE UI THREAD can send Morphic commands directly.

You can use 

 WorldState addDeferredUIMessage: aBlock

to send commands back into the UI thread.

> self submorphs is executed before openInHand is completed, which is before
> symbol is added to submorphs.
>
> Any way I can wait for HandMorph>>openInHand to complete?

Yes; we send several notifications on structure changes:

addedMorph: aNewSubmorph
 a submorph was just added to me

removedMorph: anOldSubmorph
 a submorph was just removed from me

noteNewOwner: aMorph
 I have just been made a submorph of aMorph (could be nil on deletion, as I 
recall). This is probably what you want, or use:

intoWorld: aWorld
 "The receiver has just appeared in a new world. Note:
  * aWorld can be nil (due to optimizations in other places)
  * owner is already set
  * owner's submorphs may not include receiver yet.
 Important: Keep this method fast - it is run whenever morphs are added." 

-- 
Ned Konz
http://bike-nomad.com




More information about the Squeak-dev mailing list