In case someone needs the possibility to save or even manually start one of the event functions, here is a small test based upon SamuraiCrows suggestion:
Code: Select all
global t_EventHandlers = {}
funccopy = InstallEventHandler
InstallEventHandler = Function (table)
ForEach(table, Function (ID, item)
t_EventHandlers[ID] = item
EndFunction)
funccopy(table)
EndFunction
InstallEventHandler( {OnMouseUp = Function () DebugPrint("a test") EndFunction} )
t_EventHandlers.OnMouseUp()
A little explanation of the code.
I am first making a global table called t_EventHandlers. The purpose of This table is to have every events function stored.
Next I make a copy of the function (InstallEventHandler), this is necessary since if I use InstallEventHandler directly at a later point, it will end in an endless recursive loop (=calling itself endless times).
Then comes finally the time where I replace the current InstallEventHandler function with my own version.
Notice that basically all commands in Hollywood are functions, and you can replace them with your own, and this is what I am doing here, although in this case I wouldn't really call it replacing the command, but rather expanding it, since I include the old command to the new command as well.
First I will check all the table items that come with the event handler, and put them to the t_EventHandlers table.
As an example, there is now "OnMouseUp = Function" this means there will be t_EventHandlers.OnMouseUp existing after that. similarly there could be t_EventHandlers.OnMouseDown or anything else of Hollywoods Events.
After this part is done, I am making a call to a funccopy (which is a copy of original InstallEventHandler) using the same arguments user passed to my InstallEventHandler.
Then it is time for a test.
I use InstantEventHandler to make one OnMouseUp option with a function that simply debugprints "a test".
then I call this function directly by calling it from that t_EventHandlers table, and it works.