[RESOLVED] - Component 'alias' in Module isn't applying to the component class

Hi,

i don’t know should i open a Github issue ? but posting here .

Alias not working with <component> tag:

the problem is i can’t use Alias name when using component tag, but it is working when i am providing the actual class name.

Alias working with <class> tag:
i can use alias with class tag.

what do you suggest which one will be more reliable i mean does those two tags work differently ?

The project files:

here’s my Module.xml

<?xml version="1.0" encoding="utf-8"?>
<module id="test_module">

	<resources>
		<resource path="../assets/images" prefix="images" />
	</resources>

	<components>
		<component class="ui.testcomp.CustomTestComp" alias="TestComponentSim" />
		<class name="ui.testcomp.CustomTestComp" alias="TestComponent" />
	</components>
 
</module>

my Main.xml

<?xml version="1.0" encoding="utf-8"?>
<vbox id="main" width="100%" height="100%" style="padding:15px;spacing:15px;">
	<TestComponentSim/>
    <CustomTestComp />
	<TestComponent />    	
</vbox>

my TestComponent.xml

<?xml version="1.0" encoding="utf-8"?>
<hbox>
	<textfield id="txtCount" text="0" />
	<button id="btnInc" text="INCREMENT +" />
	<button id="btnDec" text="DECREMENT -" />
</hbox>

my CustomTestComp.hx file

@:build(haxe.ui.macros.ComponentMacros.build("assets/ui/custom/TestComponent.xml"))
class CustomTestComp extends Box
{
	@:bind(txtCount.text)
	public var txtCountValue:String = "100";

	public function new()
	{
		super();
	}

	@:bind(btnInc, MouseEvent.CLICK)
	private function onIncrement(e:MouseEvent):Void
	{
		var number = Std.parseInt(txtCountValue) + 1;
		txtCountValue = Std.string(number);
	}

	@:bind(btnDec, MouseEvent.CLICK)
	private function onDecrement(e:MouseEvent):Void
	{
		var number = Std.parseInt(txtCountValue) - 1;
		txtCountValue = Std.string(number);
	}

}

Main.hx

class Main
{
	public static function main()
	{
		var app = new HaxeUIApp();
		app.ready(function()
		{
			var main:Component = ComponentMacros.buildComponent("assets/ui/main.xml");
			app.addComponent(main);
			app.start();
		});
	}
}

i really like the @:bind thing :blush: just like butterknife in java .

EDIT :

i noticed one more things when using <component> tag and if i put wrong path to the component xml

@:build(haxe.ui.macros.ComponentMacros.build("assets/ui/custom/TestComponent.xml"))

it will just compile and not render anything.

but if i use <class> tag it will give me compile time error that the path to xml is incorrect which is really helpful.

I dont think “component” is a valid node under “components”… only “class”… … that said, i think it probably should be, so i think ill add it.

EDIT: added

1 Like

perfect, actually i was following this guide