Author Topic: Is it possible to support handlers that take arguments, in EventDelegate?  (Read 2569 times)

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
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!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Is it possible to support handlers that take arguments, in EventDelegate?
« Reply #1 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.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
"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.
« Last Edit: March 29, 2014, 11:12:54 AM by wallabie »

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
@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 :)

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
@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.
« Last Edit: March 29, 2014, 11:59:05 PM by wallabie »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
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".

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Awesome, NGUI is definitely getting better.  Can't wait to try it.