Well, I have a button in library that looks like following:
public class Button {
public event Action<UIButtonX> onClicked;
//
// when button clicked, on OnClicked method is called
//
protected virtual void OnClicked () {
if (onClicked != null) onClicked (this);
}
}
When i want to handle button click, i’m writing something like:
button.onClicked += delegate{
//do something
}
or
button.onClicked += HandleButtonClick;
void HandleButtonClick(UIButton obj){
}
Now I want to pass parameter to anonymous delegate, like
button.onClicked += delegate(UIButton obj, int id) {
//do something with id
}
but compiler doesn’t allow this. How to deal that problem?
Thanks.
By the look of things you need to do something like this:
And then you can add your handler: