Question

I want to add a click event to a menu item which is created at runtime.

In Oxygene

var mi : MenuItem := new MenuItem();

In C# this would have been something like

mi.Click += EventHandler(...);

However Oxygene does not seem to use the += operator. Events seem to have been specially treated in Oxygene in a way which is different to C#. What happens when I want to use the original C# event handling so I can use the MenuItem?

Was it helpful?

Solution

Click is an event. So

mi.Click += new EventHandler(@Click);

Works, or with a lambda:

mi.Click += (s, o) -> MessageBox.Show('Clicked the menu!');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top