What does @:bind do?

ive seen it in many examples as a way to bind events, but it doesent work in vscode and instead of using @:bind, I had to use openfl’s addEventListener(); what is the purpose of it?

So @:bind is a macro that links up an event listener for you, so if you do:

@:bind(someButton, MouseEvent.CLICK)
function onSomeButton(_) {

a haxe macro will go away and add the following to the class constructor:

someButton.registerEvent(MouseEvent.CLICK, onSomeButton);

Thats all there is to it really. It just keeps things neat and tidy. When you say it “does work” can you be more specific? Is this is haxeui component based class? Can you post an example?

Also, you really shouldnt use openfl events with haxeui. You totally can because haxeui events will eventually map to openfl events, but by bypassing haxeui there is a risk that haxeui wont know about the event listener.

Take for example “disabled”, if you disable a button haxeui will pause the haxeui mouse events for it so you cant interact with it. If you added an openfl to it vai addEventListener haxeui would have no knowledge of that event and it would still be active when you disable.


thanks, it works with the built in haxe ui @:bind now! the addEventListener was imported from openfl.

is there any documentation on how this works so I can use the @: keyword more effectively?

and also why are the haxeui docs so slow? is it a server issue?