[Feature Request] Event Handler manipulation

Post Reply
Sanaki
Posts: 110
Joined: Wed Mar 09, 2011 1:30 am

[Feature Request] Event Handler manipulation

Post by Sanaki »

First, the basic question, is there a simple way to make a function to add/remove/retrieve event handlers on a script?

More importantly though, is there any way we could get a function to create a "temphandler" or such, which is in effect just an event handler link to a function? For instance: temphandler(myfunction, "test event") would make it so that whenever the event "test event" was raised, it would call myfunction() with the event's arguments, just as if it had been defined in a script manually with the event handler added there. The ability to create these permanently would be helpful as well, but not necessary with proper care in coding.

The above should be able to cover just about every need from this sort of thing, including effectively allowing the automated import and update of scripts, the creation of more dynamic and functional scripts like Iocun's path walker without requiring manual modification to adjust events, and so on.

User avatar
Omni
Posts: 131
Joined: Fri Feb 12, 2010 10:26 am

Re: [Feature Request] Event Handler manipulation

Post by Omni »

There is a function to add event handlers to a function. Not perfect. It was introduced in pre8.

Sanaki
Posts: 110
Joined: Wed Mar 09, 2011 1:30 am

Re: [Feature Request] Event Handler manipulation

Post by Sanaki »

Interesting. What is it? I'm not 100% clear on the order of versions, but I do believe both my systems should have it given that, and I haven't noticed it thus far. I'll test it out and see if my request is still valid.

User avatar
Omni
Posts: 131
Joined: Fri Feb 12, 2010 10:26 am

Re: [Feature Request] Event Handler manipulation

Post by Omni »

registerAnonymousEventHandler() I think. Something of that sort.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: [Feature Request] Event Handler manipulation

Post by Oneymus »

Code: [show] | [select all] lua
registerAnonymousEventHandler( "event", "function as a string" )

-- Example...
registerAnonymousEventHandler( "sysWindowResizeEvent", "myResizeFunction" )
No clue if you can pass actual functions; I don't believe this function is documented anywhere useful. But there it is; you cannot pass functions in tables, either.

User avatar
Omni
Posts: 131
Joined: Fri Feb 12, 2010 10:26 am

Re: [Feature Request] Event Handler manipulation

Post by Omni »

I know Heiko posted a few examples for it in the pre8 thread.

Darmir
Posts: 226
Joined: Sun May 01, 2011 6:51 pm
Contact:

Re: [Feature Request] Event Handler manipulation

Post by Darmir »

Oneymus wrote:
Code: [show] | [select all] lua
registerAnonymousEventHandler( "event", "function as a string" )

-- Example...
registerAnonymousEventHandler( "sysWindowResizeEvent", "myResizeFunction" )
No clue if you can pass actual functions; I don't believe this function is documented anywhere useful. But there it is; you cannot pass functions in tables, either.
Hey Oneymus,
Why don't you add it to the wiki? Doesn't take much. If you're not sure abou the format just add it then msg me and I will pretty it up. :)

Sanaki
Posts: 110
Joined: Wed Mar 09, 2011 1:30 am

Re: [Feature Request] Event Handler manipulation

Post by Sanaki »

I'll handle that. I found it, have been using it, but yeah, only takes string input. Still, that's workable, and potentially easier in the manner I want to use it. Seems to work fine to me as well, though gods forbid if I wanted to adjust the event handlers I set.

Post Reply