Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: AddEventHandller implementation

$
0
0
Hi furesoft,

It looks like you might want something like this:
publicvoid AddEventHandler(string name, dynamic handler)
{
    var evt = f.GetType().GetEvent(name);
    var action = new Action<object, object>((sender, args) => handler(sender, args));
    evt.AddEventHandler(f, Delegate.CreateDelegate(evt.EventHandlerType, action.Target, action.Method));
}
Keep in mind that ClearScript lets you set up event handlers directly from script code:
form.Activated.connect(function (sender, args) {
    // do something
});
Good luck!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>