Den 17.01.2011 07:18, skrev Sean P. DeNigris:
> I really like Announcements!  It's so much easier to update complex GUIs when
> you can pass state :)
>
> I hit one glitch when unsubscribing... The CollaborActive book suggests
> unsubscribing in #delete.  For complex UIs, this doesn't seem to work
> because #delete is only called for the one morph that was deleted, not for
> its submorphs (which may need to unsubscribe).
>
> I tried this:
>   MyMorph>>delete
>       super delete. "Must come first. Deleting a submorph before self =
> emergency evaluator"
>       aSubmorphThatNeedsToUnsubscribe delete.
>
>   SubmorphMentionedAbove>>delete
>       self inventory announcer unsubscribe: self.
>       super delete.
>
>
> But it seems like a lot of work and coupling.  Is there no hook that is
> guaranteed to be called when a morph is going away - i.e. it or a morph in
> the owner chain is being deleted?
>
> Thanks.
> Sean
AFAICT, #outOfWorld: might be the one you're looking for, it's called on
self and submorphs as part of #removeMorph:
So I THINK you'd get away with:
 

SubmorphMentionedAbove>>outOfWorld: aWorld
      self inventory announcer unsubscribe: self.
      super outOfWorld: aWorld
.

Cheers,
Henry

Reply via email to