I'm trying to make an app with several sub-editors. I'm writing a base Editor type that each type of editor will Extend.
What I don't understand is, how come I don't have to specify the context when I remove a hook? Surely if I have two different editors running, and I close one, it doesn't know which hook to remove and might continue calling TEditor.EventHook with the wrong context?
(In case you're wondering why I'm hiding and showing the window rather than freeing the gadget and then re-making it each time, it seems to me that if there's a Canvas gadget in the window (and there will be for most of the editors) there's nothing I can do to stop it taking more and more memory and not freeing it when the gadget is freed, is this right?)
Type TEditor ' Event Handling Method OnEvent(event:TEvent) Abstract Function EventHook:Object(id,data:Object,context:Object) Local event:TEvent = TEvent(data) Local editor:TEditor = TEditor(context) editor.OnEvent(event) Return data End Function 'Instantiation Handling Method Open() AddHook EmitEventHook,EventHook,Self If Window ShowGadget Window Else MakeWindow() End If End Method Method MakeWindow() Abstract Method Close() RemoveHook EmitEventHook,EventHook ' <<<<--- THIS BIT HideGadget Window End Method End Type
What I don't understand is, how come I don't have to specify the context when I remove a hook? Surely if I have two different editors running, and I close one, it doesn't know which hook to remove and might continue calling TEditor.EventHook with the wrong context?
(In case you're wondering why I'm hiding and showing the window rather than freeing the gadget and then re-making it each time, it seems to me that if there's a Canvas gadget in the window (and there will be for most of the editors) there's nothing I can do to stop it taking more and more memory and not freeing it when the gadget is freed, is this right?)