[squeak-dev] Execute code when a Morph is destroyed

Igor Stasenko siguctua at gmail.com
Tue Jan 6 19:48:07 UTC 2009

2009/1/6 Séverin Lemaignan <skadge at gmail.com>:
> Hello,
> I would like to execute some code (closing a serial port) when a morph
> is destroyed by an user (either by clicking on the cross or by
> drag&dropping the morph to the bin). Do you know how to do that?
Use finalization for closing any external resources being used by
squeak-based objects.

WeakRegistry default add: myObject.

   self closeAllPorts.

> As a bonus question, is it possible to detect, on the contrary, when a
> morph is restored from the bin (to reestablish the communication) ?
Don't know about morph-specifics too much.

> Thank you!
> Séverin

Best regards,
Igor Stasenko AKA sig.

More information about the Squeak-dev mailing list