Trouble with custom components in haxeui

219 views
Skip to first unread message

Nathan Hüsken

unread,
May 14, 2014, 6:29:21 AM5/14/14
to haxe...@googlegroups.com

Hey List, Hey Ian.

I am having trouble creating a custom component in haxeui following: http://haxeui.org/wiki/en/Custom_Components

I have this CustomComponent.hx:

import flash.events.MouseEvent;
import haxe.ui.toolkit.containers.HBox;
import haxe.ui.toolkit.controls.Button;
import haxe.ui.toolkit.controls.Text;
import haxe.ui.toolkit.events.UIEvent;
import haxe.ui.toolkit.core.ClassManager;

class CustomComponent extends HBox {

    var label: Text;
    var button: Button;

    public function new() {
        super();

        style.borderColor = 0x0080C0;
        style.borderSize = 1;

        button = new Button();
        button.text = "button";
        button.onClick = onClickButton;
        addChild(button);

        label = new Text();
        label.text = "Default Text";
        addChild(label);

    }

    private function onClickButton(e:UIEvent):Void {
        label.text = "Button Clicked!";
    }

}

and this Main.hx:

import haxe.ui.toolkit.core.Macros;
import haxe.ui.toolkit.core.Toolkit;
import haxe.ui.toolkit.core.Root;
import haxe.ui.toolkit.controls.Button;
import haxe.ui.toolkit.core.ClassManager;

class Main {
    public static function main() {
        Macros.addStyleSheet("styles/gradient/gradient.css");
        ClassManager.instance.registerComponentClass(CustomComponent, "customcomponent");
        Toolkit.init();
        Toolkit.openFullscreen(function(root:Root) {
          Toolkit.processXmlResource("assets/view.xml");
        });
    }
}

this is my view.xml:

<?xml version="1.0" encoding="utf-8" ?>
<vbox >
    <customcomponent/>
</vbox>

now I compile it:

> lime test linux

and get a windows showing nothing … (not as advertised on the haxeui site).
Why?

Thanks!
Nathan

signature.asc

Ian Harrigan

unread,
May 14, 2014, 2:39:08 PM5/14/14
to haxe...@googlegroups.com
Hi Nathan,

I didnt write that wiki entry so ill double check that its correct/accurate up-to-date, ill go over the code also when i get a moment and see what the problem is, but it looks like it should work. 

Cheers,
Ian

Nathan Hüsken

unread,
May 14, 2014, 2:49:52 PM5/14/14
to haxe...@googlegroups.com

Hey,

Stupid me.
There should be a:

          root.addChild(Toolkit.processXmlResource("assets/view.xml"));

in the code. Now it works.

Sorry for the disturbance :).

Cheers,
Nathan

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Ian Harrigan

unread,
May 14, 2014, 2:53:07 PM5/14/14
to haxe...@googlegroups.com
Ok, well, i literally just copied and pasted your code into the relevant files, and got this on flash:



Ian Harrigan

unread,
May 14, 2014, 2:54:09 PM5/14/14
to haxe...@googlegroups.com
Ok, cool... glad its fixed..

Cheers,
Ian

Nathan Hüsken

unread,
May 15, 2014, 4:19:51 AM5/15/14
to haxe...@googlegroups.com
That is interesting ... I only get that result if I add the processed xml to the root. Otherwise I get a white screen ... strange.


On 05/14/2014 08:53 PM, Ian Harrigan wrote:
Ok, well, i literally just copied and pasted your code into the relevant files, and got this on flash:



--
signature.asc

Ian Harrigan

unread,
May 16, 2014, 8:57:38 AM5/16/14
to haxe...@googlegroups.com
Yeah, i mean i added and loaded it in the xml too... if i hadnt have i wouldnt have expected to see it either... ;)
Reply all
Reply to author
Forward
0 new messages