HaxeUI Tutorial

XML Layout File and HaxeUI Objects

John Gabriele

Under the hood, HaxeUI uses a macro to convert your assets/main.xml file contents into HaxeUI Component code. There is a one-to-one correspondence between the xml and the generated object. For example, a checkbox like:


If you accidentally tried to use an attribute in your xml for which checkbox doesn’t have a property (ex., <checkbox loudness="..."), then you’d get a compilation error.

To see which properties the various GUI components support, see the API docs. The info in there is quite detailed.

The API Docs

The API docs contain a lot of juicy morsels of info. For example, in the docs for CheckBox you’ll notice:

  • there’s breadcrumbs plus a diagram showing the inheritance hierarchy for haxe.ui.components.CheckBox.

  • There are separate “doc groups”, to split out all the properties and methods into various categories:

    • Properties
    • Methods
    • Display tree related properties and methods
    • Event related properties and methods
    • Layout related properties and methods
    • Script related properties and methods
    • Style properties
    • Style related properties and methods

    Doc groups have checkboxes above them so you can show/hide properties and methods of ancestor classes.

  • There are little colored boxes/labels on the right with names including “behaviour”, “bindable”, “clonable”, etc. These indicate… TODO

A Shortcut: Scripts

HaxeUI provides a little shortcut you can use when you want a widget to have a short handler that doesn’t merit writing a whole separate handler function in your class. You can add the handler as a “script” right in the main.xml file, for example:

would produce:

script handler
script handler

That script code is written in slightly-modified hscript, a dynamically-typed subset of Haxe.