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

    famous-alarm-22563

    12/08/2022, 8:11 AM
    must have a superclass of haxe.ui.component...
  • f

    famous-alarm-22563

    12/08/2022, 8:11 AM
    So.. I can't do this either..
  • f

    famous-alarm-22563

    12/08/2022, 8:11 AM
    hmmmmm
  • b

    bright-gpu-74537

    12/08/2022, 8:12 AM
    hmmm, its a good point, and i think someone brought up something like this before
  • b

    bright-gpu-74537

    12/08/2022, 8:12 AM
    that if you add to Screen, then halign / valign dont work... it makes sense they dont work, but it is unexpected
  • f

    famous-alarm-22563

    12/08/2022, 8:12 AM
    it would have been super convenient because now i need to create a setupUI function instead its a lot cleaner just ot have a static variable....
  • b

    bright-gpu-74537

    12/08/2022, 8:14 AM
    yeah, i think for now you'll have to center it manually, but since you are the 2nd (or maybe even 3rd) person who hit this, i think thats enough of hint that it should probably be added, ie, that top level components should respond to h/valign
  • f

    famous-alarm-22563

    12/08/2022, 8:16 AM
    what about having Component variables in other classes?
  • b

    bright-gpu-74537

    12/08/2022, 8:16 AM
    what do you mean?
  • f

    famous-alarm-22563

    12/08/2022, 8:16 AM
    this.ui = ComponentMacros.build("assets/views/menu-view.xml");
  • f

    famous-alarm-22563

    12/08/2022, 8:16 AM
    this won't work because the superclass must be a haxeui class....
  • f

    famous-alarm-22563

    12/08/2022, 8:16 AM
    :/
  • f

    famous-alarm-22563

    12/08/2022, 8:17 AM
    so... I can't have xml inside other classes?
  • b

    bright-gpu-74537

    12/08/2022, 8:17 AM
    > this won't work because the superclass must be a haxeui class. i dont follow
  • b

    bright-gpu-74537

    12/08/2022, 8:17 AM
    >
    this.ui = ComponentMacros.build("assets/views/menu-view.xml");
    that would be fine... build macro wouldnt be
  • b

    bright-gpu-74537

    12/08/2022, 8:18 AM
    @:build(....)
    needs to have a super class of a haxeui component
  • f

    famous-alarm-22563

    12/08/2022, 8:18 AM
    Copy code
    class MenuState extends FlxState
    {
        var score:Int;
        var ui:Component;
    
        override public function new(score)
        {
            super();
            this.score = score;
        }
    
        override public function create()
        {
            super.create();
            
            this.ui = ComponentMacros.build("assets/views/menu-view.xml");
            add(this.ui);
        }
    }
    Here is an example with most of my other code taken out ```
  • b

    bright-gpu-74537

    12/08/2022, 8:19 AM
    OK, and thats fine, no? (btw, i would consider making "ui" a custom component, but thats neither here nor there at the moment)
  • f

    famous-alarm-22563

    12/08/2022, 8:19 AM
    disclaimer: I haven't looked at haxe macros yet so this ixs probably an error on my end
  • f

    famous-alarm-22563

    12/08/2022, 8:20 AM
    its not fine.. i am getting this error ..
  • f

    famous-alarm-22563

    12/08/2022, 8:20 AM
    must have a superclass of haxe.ui.core.Component
    on the line where I do
    this.ui = ...
  • b

    bright-gpu-74537

    12/08/2022, 8:20 AM
    ah, hang on, i think you are using the wrong call
  • b

    bright-gpu-74537

    12/08/2022, 8:23 AM
    ok, so yeah, the call you want is "ComponentMacros.buildComponent"... that will spit out an expression (Expr) that will be the result of your xml in code. The "ComponentMacros.build" call is for build macros for custom component classes
  • b

    bright-gpu-74537

    12/08/2022, 8:24 AM
    however, these calls are depricated, and you should use the new ones: *
    'haxe.ui.macros.ComponentMacros.build' is deprecated, use 'haxe.ui.ComponentBuilder.build' instead
    *
    'haxe.ui.macros.ComponentMacros.buildComponent' is deprecated, use 'haxe.ui.ComponentBuilder.fromFile' instead
    *
    'haxe.ui.macros.ComponentMacros.buildComponentFromString' is deprecated, use 'haxe.ui.ComponentBuilder.fromString' instead
  • f

    famous-alarm-22563

    12/08/2022, 8:24 AM
    Oh, oops... that seems like something lots of people would fall into. You might want to add a helpful error message 🙂
  • b

    bright-gpu-74537

    12/08/2022, 8:24 AM
    so in your case
    haxe.ui.ComponentBuilder.fromFile
  • f

    famous-alarm-22563

    12/08/2022, 8:25 AM
    hmm apparently half my code is deprecated
  • b

    bright-gpu-74537

    12/08/2022, 8:25 AM
    yeah, thats why ive renamed the calls, i did have deprecation warnings on them, but for some reason they were showing al the time for me (even if i didnt use them - vscode thing i guess)
  • f

    famous-alarm-22563

    12/08/2022, 8:25 AM
    might wanna add warnings to the entire componentmacros module
  • f

    famous-alarm-22563

    12/08/2022, 8:26 AM
    a trace would do wonders here
1...132513261327...1687Latest