bright-gpu-74537
06/19/2020, 5:33 PMbright-gpu-74537
06/19/2020, 5:34 PMhandsome-television-62908
06/19/2020, 5:37 PM@:build()
functionality to modules.xml components? I was thinking about implementing this (not as a feature of modules.xml though) for my project in some fashionbright-gpu-74537
06/19/2020, 5:38 PMhandsome-television-62908
06/19/2020, 5:40 PMhaxe
@:build(...)
class MyDialog extends Dialog { // thats it!
}
If all I wanted to do was access IDs and buttons or the like in components then adding build=true
to a component in the module file would just expose the same functionality for a componentbright-gpu-74537
06/19/2020, 5:41 PMbright-gpu-74537
06/19/2020, 5:41 PMbright-gpu-74537
06/19/2020, 5:41 PMxml
<components>
<class file="custom/custom1.xml" alias="CustomAlias" />
<class folder="custom" />
</components>
bright-gpu-74537
06/19/2020, 5:41 PMhandsome-television-62908
06/19/2020, 5:41 PMbright-gpu-74537
06/19/2020, 5:41 PMbright-gpu-74537
06/19/2020, 5:42 PMhandsome-television-62908
06/19/2020, 5:42 PMbright-gpu-74537
06/19/2020, 5:42 PMbright-gpu-74537
06/19/2020, 5:43 PMbright-gpu-74537
06/19/2020, 5:44 PMbright-gpu-74537
06/19/2020, 5:44 PM// MyCustomDialog.xml
<dialog>
<label id="bob" />
</dialog>
// module.xml
<components>
<class file="MyCustomDialog.xml" />
</components>
// Main.hx
var d = new MyCustomDialog();
d.bob = "tim";
d.show();
bright-gpu-74537
06/19/2020, 5:44 PMbright-gpu-74537
06/19/2020, 5:45 PMbright-gpu-74537
06/19/2020, 5:48 PMbright-gpu-74537
06/19/2020, 5:48 PMbright-gpu-74537
06/19/2020, 5:49 PMbright-gpu-74537
06/19/2020, 5:50 PM<hbox width="100%" />
becomes:bright-gpu-74537
06/19/2020, 5:51 PMclass MyComponent extends HBox {
public function new() {
percentWidth = 100;
}
}
bright-gpu-74537
06/19/2020, 5:51 PM<vbox id="tim" />
becomes:bright-gpu-74537
06/19/2020, 5:51 PMclass MyComponent extends VBox {
public function new() {
id = "tim;
}
}
bright-gpu-74537
06/19/2020, 5:51 PMbright-gpu-74537
06/19/2020, 6:48 PMbright-gpu-74537
06/19/2020, 6:48 PMhaxe
main.findComponent("showDialog2", Button).onClick = function(e) {
var dialog2 = new assets.custom.Test2();
// wont work as the custom component isnt actually a dialog
dialog2.show();
// the actual dialog is a child now of the custom component from the xml file
var actualDialog = dialog2.findComponent(Dialog);
// also wont work as this isnt the custom component anymore, so build macro hasnt added fields
//actualDialog.theValue.text = "The new value 2";
actualDialog.show();
}
bright-gpu-74537
06/19/2020, 6:51 PM