import System; import System.Drawing; import Accessibility; import System.Windows.Forms; class Functor { var h = null; function Handler(sender, e : EventArgs){ if(h) h(sender, e); } function Functor(handler){ h = handler; } } class EventTestForm extends Form { var btn : Button; var a = null; function EventTestForm() { btn = new Button; btn.Text = "Fire Event"; btn.Location = new Point(120, 200); Controls.Add(btn); var t = 'inner variable'; btn.add_Click(new Functor(function(){ MessageBox.Show(t); }).Handler); } } Application.EnableVisualStyles(); Application.Run(new EventTestForm); jsc /target:winexe test.js test