Custom components - Binding events (github docs)

Just a note
I was checking the docs on github

And I’ve noticed that if the “e” parameters isn’t typed, the properties (or at least te text for TextField) can’t be retrieved.

In this case e.target.text return null (as e.target.id for example)

@:bind(settingsName, UIEvent.CHANGE)
function onNameChange(e) {
    trace(e.target.id);
    this.control.text = e.target.text;
}

typing the parameters
onNameChange(e:UIEvent)
solve the issue.
Maybe it could be worth to update the doc adding a textfield sample ?

I have a related issue in a kha based project.

@:xml('
<hbox>
	<button id="b1" text="b1" />
	<button id="b2" text="b2" />
</hbox>
')
class View extends HBox {
	public function new() {
		super();
	}

	@:bind(b1, UIEvent.CHANGE)
	function onB1( event: UIEvent ) {
		trace('b1');
	}

	@:bind(b2, MouseEvent.CLICK)
	function onB2( event: MouseEvent ) {
		trace('b2');
	}
}

And i just get some warnings when the project starts.

haxe/ui/macros/Macros.hx:274: WARNING: could not find component to regsiter event (b2)
haxe/ui/macros/Macros.hx:274: WARNING: could not find component to regsiter event (b1)

What happen if you try to @:build from a separate xml ?

Hm cool, that actually works.

Sounds like a bug in @:xml then… ill check it out

Meanwhile I’ve found another strange issue trying to bind an event in a class that create and shows another component (in fact i’m opening a settings view from a component and I need to run something on the component after the settings view is closed )

In the main component class (myTool) I have this

var settingsView = new MySettings(this);
[see code blocks below]
mainview.addComponent(settingsView);

this works

    settingsView.registerEvent(MyEvent.SETTINGS_CLOSED, function(e) {
        this.updateHttpUrl();
        this.startPolling();
    });

this doesn’t

        @:bind(settingsView, MyEvent.SETTINGS_CLOSED)
        function onSettingClosed(e) {
            this.updateHttpUrl();
            this.startPolling();
        }

I’ve also tried moving the addComponent before binding

Just pop up to my mind that this last one could be due to mine parent/child class structure

@:xml should be working again properly now, was a tiny change (code for binding was being added before ui was built)

Looking at other issues today