RemoveHook - no context parameter?
BlitzMax Forums/BlitzMax Programming/RemoveHook - no context parameter?
| ||
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.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?) |
| ||
denzilquixode: What I don't understand is, how come I don't have to specify the context when I remove a hook? I read the source files and it seems like RemoveHook removes the hooks in reverse order they were added.But I don't think this works correctly. I think there should a context parameter be added to RemoveHook. |