Morph reacting to Window being closed

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

Morph reacting to Window being closed

Peter Uhnak
Hi,

how can a Morph react to its parent window being closed?

E.g.

Morph subclass: #MyMorph.
MyMorph new openInWindow

how can MyMorph cleanup itself on window close?

I thought Morph>>delete would do the trick, but it is not being called.

Thanks,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: Morph reacting to Window being closed

HilaireFernandes
Hi Peter,

I think you have two options:

1. Specialize the Window and use your own delete method to do your
additional cleaning. This is what I do in Dr. Geo.

2. Use the WindowClosed announcement from system window to catch the
signal from the morph you want to clean

Hilaire

Le 29/07/2018 à 13:35, Peter Uhnák a écrit :

> how can a Morph react to its parent window being closed?
>
> E.g.
>
> Morph subclass: #MyMorph.
> MyMorph new openInWindow
>
> how can MyMorph cleanup itself on window close?
>
> I thought Morph>>delete would do the trick, but it is not being called.
>
> Thanks,
> Peter

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: Morph reacting to Window being closed

Henrik-Nergaard
In reply to this post by Peter Uhnak
Hi Peter,

There are two methods which can be used for this purpose.
#outOfWorld:
#announceDeleted

Both are called recursively down the morph tree from the window.

If you need to stop the window or provide a dialog then you should create a
subclass of Model and use that to keep references to things that need
cleanup and control the closing and other events.

Best regards,
Henrik




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Reply | Threaded
Open this post in threaded view
|

Re: Morph reacting to Window being closed

Peter Uhnak
Thank you Henrik,

#outOfWorld: was the best solution to me, as I can use it even when I don't control the window/container the morph is embedded in.

Peter

On Sun, Jul 29, 2018 at 10:16 PM, Henrik-Nergaard <[hidden email]> wrote:
Hi Peter,

There are two methods which can be used for this purpose.
#outOfWorld:
#announceDeleted

Both are called recursively down the morph tree from the window.

If you need to stop the window or provide a dialog then you should create a
subclass of Model and use that to keep references to things that need
cleanup and control the closing and other events.

Best regards,
Henrik




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html