Morph reacting to Window being closed
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
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
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
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 <draagren@outlook.com> 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
participants (3)
-
Henrik-Nergaard -
Hilaire -
Peter Uhnák