How to pass delegate(C#) to Haxe function? -
i want this:
c#:
class csharpclass { void foo() { haxeclass h = new haxeclass(); h.bar( () => {} ); } }
haxe:
@:expose class haxeclass { public bar(f: void->void): void { f(); } }
generated c# code requires function parameter haxe.lang.function, can find no converter delegate haxe.lang.function. have write listener class?
you can use cs.system.action_* that.
c#:
class csharpclass { void foo() { haxeclass h = new haxeclass(); h.bar(handler); } void handler(str:string){} }
haxe:
class haxeclass { public bar(f: cs.system.action_1<string>): void { f.invoke("foobar"); } }
note 1 actions more 1 parameter (action_1, action_2, etc) aren't available when building against .net 2.0 (the current default), .net 3.0 , .net 4.0 .
note 2 far know there no action_0 in cs.system package. nevertheless can created with:
@:native("system.action") extern class action_0 { function invoke():void; }
Comments
Post a Comment