https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • f

    fast-rain-20339

    07/30/2020, 3:14 AM
    What I suspect is the case is the button is there, but you're operating with it before it's been set up, added to the screen, etc.
  • f

    fast-rain-20339

    07/30/2020, 3:14 AM
    You may have to delay by registering a READY event.
  • k

    kind-policeman-40412

    07/30/2020, 3:14 AM
    But actually I've tried to trace my component and it prints it's type as [object Box]
  • f

    fast-rain-20339

    07/30/2020, 3:14 AM
    Yep, it will do. It's a Box with various child components.
  • k

    kind-policeman-40412

    07/30/2020, 3:15 AM
    hmmm
  • k

    kind-policeman-40412

    07/30/2020, 3:15 AM
    You mean it's children are created only when the component is added to stage via addChild? Cause I'm using openfl backend.
  • f

    fast-rain-20339

    07/30/2020, 3:16 AM
    Maybe, I'm not entirely sure when children get initialised. A safe bet would be in a
    READY
    event handler though.
  • k

    kind-policeman-40412

    07/30/2020, 3:17 AM
    Sure, I'm just trying to find some logic behind )
  • f

    fast-rain-20339

    07/30/2020, 3:17 AM
    If you print
    yourBuildComponent.joinButton
    though and it's null (on a static target), that means it certainly is a field. If it wasn't a field, it would crash.
  • f

    fast-rain-20339

    07/30/2020, 3:18 AM
    (As if you'd done
    yourBuildComponent.jsdlkfjsd
    )
  • f

    fast-rain-20339

    07/30/2020, 3:18 AM
    Actually, it wouldn't even build.
  • k

    kind-policeman-40412

    07/30/2020, 3:18 AM
    yeah. I've thought about just that that's why it returns null. Just cannot find it in some map.
  • k

    kind-policeman-40412

    07/30/2020, 3:19 AM
    thanks again. will try 🙂
  • k

    kind-policeman-40412

    07/30/2020, 4:16 AM
    Ok, but how to properly add event listeners because there's literally no docs about that? I spent some time digging into the HaxeUI code and found there's a
    ComponentEvents.registerEvent
    method. And when I tried to use it my code does compile but in runtime I've got an
    Uncaught exception - Invalid call
    on line
    myBuiltComponent.registerEvent(UIEvent.READY, onReady);
    Of course I've created an onReady method in the same class
    private function onReady(event:UIEvent):Void
    . What I am doing wrong?
  • f

    fast-rain-20339

    07/30/2020, 4:18 AM
    Hm, how frustrating. Are you able to share your code?
  • f

    fast-rain-20339

    07/30/2020, 4:20 AM
    Also, fwiw, I'm not a pro, Ian will be on in a little while and will likely be much better at helping 😄
  • f

    fast-rain-20339

    07/30/2020, 4:21 AM
    I've been struggling too, it looks like tabviews ignore
    hidden
    😛
  • k

    kind-policeman-40412

    07/30/2020, 4:28 AM
    I cannot share the whole project. But the code related to this problem is well isolated and contains only 2 methods.
    Copy code
    Haxe
    private function createUI():Void
        {
            ui = ComponentMacros.buildComponent("assets/ui/lobby/main.xml");
            ui.registerEvent(UIEvent.READY, onReady);
            container.addChild(ui);
        }
    
        private function onReady(event:UIEvent):Void
        {
            trace('onReady -> ui:', ui);
            trace('onReady -> event:', event);
        }
    Where ui is a class property
    private var ui:Dynamic;
    Because only Dynamic or Box type allows me to compile this code but with Box it does not compile when I try to access joinButton. In a code above I've removed joinButton to test how event register works.
  • k

    kind-policeman-40412

    07/30/2020, 4:29 AM
    Without this the ui is built and it works.
  • f

    fast-rain-20339

    07/30/2020, 4:31 AM
    As I've said, I don't use
    buildComponent
    , Ian will be more help, but the type's at least make sense.
    Box
    , the Haxe UI class, doesn't have a
    myButton
    field, that's added by the macro. I wonder if you can do the create UI thing on the
    var
    line so that the type automatically gets set?
  • f

    fast-rain-20339

    07/30/2020, 4:31 AM
    Though Dynamic should just avoid all that 🤔
  • k

    kind-policeman-40412

    07/30/2020, 4:32 AM
    Of course I could use the local var but then I cannot do container.removeChild(ui); in my onDestroy() method 🙂
  • f

    fast-rain-20339

    07/30/2020, 4:32 AM
    Mh, I see.
  • f

    fast-rain-20339

    07/30/2020, 4:33 AM
    So, does onReady get called? I'm trying to figure out the issue. Does it still crash on event register?
  • k

    kind-policeman-40412

    07/30/2020, 4:34 AM
    No, it spits exception in runtime on ui.registerEvent line.
  • f

    fast-rain-20339

    07/30/2020, 4:34 AM
    Is there a stacktrace?
  • f

    fast-rain-20339

    07/30/2020, 4:35 AM
    (that involves haxe ui?)
  • k

    kind-policeman-40412

    07/30/2020, 4:35 AM
    I mean, yeah it crashes. Yeah wait a sec.
  • k

    kind-policeman-40412

    07/30/2020, 4:36 AM
    hmm cannot add message in spoiler ))
  • f

    fast-rain-20339

    07/30/2020, 4:37 AM
    Wow, that is surprisingly unhelpful
1...323324325...1687Latest