Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: vexe on February 26, 2014, 11:42:19 AM

Title: Is it possible to support handlers that take arguments, in EventDelegate?
Post by: vexe on February 26, 2014, 11:42:19 AM
i.e. support handlers of type "void handler(T arg)" and not just "void handler(void)" - (By handler I mean the target method to be called in the MB to be notified)

Thanks!
Title: Re: Is it possible to support handlers that take arguments, in EventDelegate?
Post by: ArenMook on February 26, 2014, 02:26:37 PM
And what would set this argument? When you bind a delegate, you're binding a function to be called, nothing more. I may add the ability to pass arguments in the near future though.
Title: Re: Is it possible to support handlers that take arguments, in EventDelegate?
Post by: wallabie on March 29, 2014, 11:03:37 AM
"And what would set this argument?"  Let us decide how to set this argument.  Don't force us to not being able to do this. 

There are many use cases for adding arguments.  I'm running into this problem already.  Please do not lock us into a certain way of doing event programming.  It is common practice to be able to send arguments in an event.  The event system is at the core of any GUI system and not being able to send along a payload is causing too much restrictions.

Edit:  I really need this functionality now, after hours of frustrations and only to discover that the event system doesn't support this basic event programing paradigm. 

Can you please post a fix that I can add to the EventDelegate file ?

Cheers.
Title: Re: Is it possible to support handlers that take arguments, in EventDelegate?
Post by: vexe on March 29, 2014, 11:14:13 AM
@wallabie: I couldn't wait actually - so I made mine - have a look https://www.youtube.com/watch?v=Z3CNrgU8xnY&feature=youtu.be - I'll be releasing it soon - just working around some quirks :)
Title: Re: Is it possible to support handlers that take arguments, in EventDelegate?
Post by: wallabie on March 29, 2014, 11:47:22 PM
@vexe,

Cool that you've made your own.   I'm definitely interested to check it out when you are finished.

But really, not having payload support in an event system is really missing the point.  Leaving this functionality out based on the assumption that "who will supply the arguments to the delegate" is forcing us into a very limited view of how to solve problems using the event system.  An API like NGUI must realize that the set of problems and solutions that are required are much greater than any one person can ever anticipate.  It's the job of the API to provide enough flexibility and not to dictate how the solutions should come.

 Every Event system I've seen has support for Payloads.  This is oversight that has to be fixed by NGUI itself so that we do not need to re-apply our own work around with each new update - and these NGUI updates are coming fast.  Let's hope that the next update has this fix. 

Cheers.
Title: Re: Is it possible to support handlers that take arguments, in EventDelegate?
Post by: ArenMook on March 30, 2014, 07:31:33 AM
This is already a part of 3.5.6 as explained in the video: https://www.youtube.com/watch?v=K3lvXIvJFKc&list=UUQGZdUwzE8gmvgjomZSNFJg

If you have Pro, you can use it as of a few days ago. Everyone else will get to use it when I release it when I deem 3.5.6 "ready".
Title: Re: Is it possible to support handlers that take arguments, in EventDelegate?
Post by: wallabie on March 30, 2014, 02:36:19 PM
Awesome, NGUI is definitely getting better.  Can't wait to try it.