x


Accessing C# Delegate from Javascript

What is the JavaScript equivalent of the C#... playButton.onTouchUpInside += sender => Debug.Log( "button touched" ); ?

I’m trying to use @prime_31’s UIToolkit, but all the examples that use it use it with C# - which I don’t know and don’t currently have time to learn.

more ▼

asked Jul 17 '11 at 06:48 PM

Toxic Blob gravatar image

Toxic Blob
656 18 20 33

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You cannot declare delegates in js, but you can use function types to add methods to delegates created in a C# class.

  someDelegate += MyMethod;
  someDelegate += function() {
            Debug.Log("Anonymous Method"); 
            };
  function MyMethod() {
  }
more ▼

answered Jul 17 '11 at 07:08 PM

Peter G gravatar image

Peter G
15k 16 44 136

That works! Thank you.

Jul 17 '11 at 07:58 PM Toxic Blob
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4149
x3456
x31
x17

asked: Jul 17 '11 at 06:48 PM

Seen: 1601 times

Last Updated: Jul 17 '11 at 07:58 PM