handsome-television-62908
06/19/2020, 4:55 PMcomponent.findComponent('').onClick = ..
breaks on compile? Looks like the compiler code for type inference might be broken in this specific case. . . Since it doesn't seem to be able to recognize that Component
can be used as { onClick: (e)->Void}
I am using whatever Kha version is on VSCode right now - but I'm going to take a wild guess this is just a compiler problem. Is anyone not getting that sort of problem?bright-gpu-74537
06/19/2020, 4:59 PMbright-gpu-74537
06/19/2020, 4:59 PMfindComponent(..., Button).onClick
bright-gpu-74537
06/19/2020, 5:00 PMbright-gpu-74537
06/19/2020, 5:00 PMhandsome-television-62908
06/19/2020, 5:03 PMvar name:Button
to the same effect so I imagine it's nearly the same result... But I'm curious - you mentioned macros
. What macros are you referring to? all I know are the custom component onesbright-gpu-74537
06/19/2020, 5:03 PMvar button:Button = findComponent(...)
has the same effectbright-gpu-74537
06/19/2020, 5:05 PMbright-gpu-74537
06/19/2020, 5:05 PMbright-gpu-74537
06/19/2020, 5:05 PMbright-gpu-74537
06/19/2020, 5:06 PMbright-gpu-74537
06/19/2020, 5:06 PMhaxe
@:build(haxe.ui.macros.ComponentMacros.build("assets/my-component.xml")
class MyComponent extends HBox {
@:bind(textfield.text)
public var textfieldText:String = "10";
@:bind(deinc, MouseEvent.CLICK)
function onDeinc(e) {
var n = Std.parseInt(textfieldText) - 1;
textfieldText = Std.string(n);
}
@:bind(inc, MouseEvent.CLICK)
function onInc(e) {
var n = Std.parseInt(textfieldText) + 1;
textfieldText = Std.string(n);
}
}
bright-gpu-74537
06/19/2020, 5:07 PMbright-gpu-74537
06/19/2020, 5:08 PM@:bind(myButton, MouseEvent.CLICK)
handsome-television-62908
06/19/2020, 5:13 PMhandsome-television-62908
06/19/2020, 5:13 PMbright-gpu-74537
06/19/2020, 5:14 PMclever-oil-61353
06/19/2020, 5:15 PMhandsome-television-62908
06/19/2020, 5:22 PM(new MyComponent()).button.onClick = this.performAction;
removes all the boilerplate I'd otherwise have to do for a new class... But I know there's definitely a number of tricks you can do with built components to also make pretty nice and composable - which I'll definitely use with time!bright-gpu-74537
06/19/2020, 5:23 PM(new MyComponent()).button.onClick
will work with custom components, in fact, think its the only way that would work, otherwise you need a (new MyComponent()).findComponent(..., Button).onClick
bright-gpu-74537
06/19/2020, 5:24 PMbright-gpu-74537
06/19/2020, 5:25 PMbright-gpu-74537
06/19/2020, 5:27 PMhaxe
@:build(...)
class MyDialog extends Dialog { // thats it!
@:bind(something.text) public var something;
}
---
var d = new MyDialog();
d.title = "My Title";
d.something = "bob";
d.somethingElse.text = "tim";
d.show();
bright-gpu-74537
06/19/2020, 5:28 PMhandsome-television-62908
06/19/2020, 5:29 PMbright-gpu-74537
06/19/2020, 5:30 PMbright-gpu-74537
06/19/2020, 5:31 PMbright-gpu-74537
06/19/2020, 5:31 PMclass MyButton extends Button
wont work with <mybutton>
in xml without the module entry exposing itbright-gpu-74537
06/19/2020, 5:32 PMbright-gpu-74537
06/19/2020, 5:32 PM