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

    bright-gpu-74537

    02/21/2020, 4:56 PM
    should work i think (but as you have found it doesnt at the moment), its a totally valid use
  • n

    nutritious-boots-87264

    02/21/2020, 4:59 PM
    For my use cases accessing them using generated member variables (which should be fixed now) is good enough and checks at compile time that name and types are correct
  • b

    bright-gpu-74537

    02/21/2020, 5:00 PM
    yeah, for sure, i get it for your usecase (which is almost certainly how i would have used it also) but in reality it should work with findComponent also for runtime and without having to setup a build class
  • b

    bright-gpu-74537

    02/21/2020, 6:48 PM
    https://twitter.com/IanHarrigan1982/status/1230926430055403520
  • n

    nutritious-boots-87264

    02/22/2020, 4:39 PM
    @User What's your opinion on using named members for the
    :bind(id, event)
    macro? I would prefer getting a compile time error in case of incorrectly spelled instead of runtime one. If it's necessary to preserve compatibility with old one, it can be called bindStatic or something like that.
  • b

    bright-gpu-74537

    02/23/2020, 12:52 PM
    ^^ in what sense? Does it also use findComponent??
  • b

    bright-gpu-74537

    02/23/2020, 12:54 PM
    im not sure there is any reason to maintain compatibility, if it is using findComponent under the hood then it sounds like another enhancement to use the var directly (which is actually what i thought it was doing to be honest)
  • u

    user

    02/25/2020, 7:25 PM
    How do you handle data modifications within haxeui in your apps. Say you have a typedef that represents your data and you want to update each of it's fields? I am asking because using Zui makes it easy to modify data without casting and switch case parsing of the Id of a component. The ui returns the value when its interacted with. Example:`var newText= ui.textInput(oldText); ` Basically, I want to know if you found an easier way to handle data modifications with the event system.
  • u

    user

    02/25/2020, 7:25 PM
    ^ @bright-gpu-74537
  • u

    user

    02/25/2020, 7:29 PM
    I think that its the immediate mode design of Zui that enables this and it isnt applicable with UIEvent systems but I am curious how you handle this in your apps because when an app complexifies, understanding when and how ui events are fired can add complexity to the understanding of flow.
  • u

    user

    02/25/2020, 9:59 PM
    Btw the design I used is probably flawed(with switch case and casting from component to more specified component).
  • b

    bright-gpu-74537

    02/25/2020, 11:02 PM
    i use custom components alot but also itemrenders i think would solve your woes
  • b

    bright-gpu-74537

    02/25/2020, 11:02 PM
    are you basically saying "how do i map this typedef to the UI" ?
  • b

    bright-gpu-74537

    02/25/2020, 11:03 PM
    what do you mean about the switch?
  • u

    user

    02/26/2020, 3:16 AM
    I will share screen shots tommorrow because I understand its quite vague as I explained it. But yes > are you basically saying "how do i map this typedef to the UI" ? @bright-gpu-74537
  • u

    user

    02/26/2020, 3:17 AM
    I did it in a certain way but I think I tried to abstract too much maybe. Anyways screen shots tommorrow morning(your afternoon I think).
  • u

    user

    02/26/2020, 3:20 AM
    Btw with ItemRenderers it seems we have to create a separate representation to make it work(well from what I did). For example, I have a json that has a width property I cant have it be a direct ref since it wont builds because all haxeui components have an width var.
  • u

    user

    02/26/2020, 3:34 PM
    @User switch case:
  • u

    user

    02/26/2020, 3:35 PM
    Its goes for longer then this but thats the way I do it at this time.
  • b

    bright-gpu-74537

    02/26/2020, 4:30 PM
    @User - i guess i would do something like this:
  • b

    bright-gpu-74537

    02/26/2020, 4:30 PM
    Copy code
    xml
    <?xml version="1.0" encoding="utf-8" ?>
    <vbox>
        <hslider id="xpos" />
        <hslider id="ypos" />
        <hslider id="zpos" />
        <checkbox id="boolInput" />
        <textfield id="stringInput" />
    </vbox>
  • b

    bright-gpu-74537

    02/26/2020, 4:30 PM
    Copy code
    haxe
    import haxe.ui.containers.Box;
    import haxe.ui.events.UIEvent;
    
    typedef Data = {
        @:optional public var x:Float;
        @:optional public var y:Float;
        @:optional public var z:Float;
        @:optional public var check:Bool;
        @:optional public var text:Float;
    }
    
    @:build(haxe.ui.macros.ComponentMacros.build("assets/test_c.xml"))
    class TestComponent extends Box {
        private var _data:Data = {};
        
        public function new() {
            super();
        }
        
        @:bind(xpos, UIEvent.CHANGE)
        @:bind(ypos, UIEvent.CHANGE)
        @:bind(zpos, UIEvent.CHANGE)
        @:bind(boolInput, UIEvent.CHANGE)
        @:bind(stringInput, UIEvent.CHANGE)
        private function onValueChanged(e:UIEvent) {
            switch (e.target.id) {
                case "xpos":
                    _data.x = e.target.value;
                case "ypos":
                    _data.y = e.target.value;
                case "zpos":
                    _data.z = e.target.value;
                case "boolInput":
                    _data.check = e.target.value;
                case "stringInput":
                    _data.text = e.target.value;
            }
            
            trace(_data);
        }
    }
  • b

    bright-gpu-74537

    02/26/2020, 4:31 PM
    i still dont really like that switch though... would be nice if the @:bind macro could do something about that
  • b

    bright-gpu-74537

    02/26/2020, 4:31 PM
    better than using reflection though i think
  • b

    bright-gpu-74537

    02/26/2020, 4:32 PM
    i saw someone else using haxeui in a pretty novel way doing something very similar, it was public, let me see if i can find it
  • b

    bright-gpu-74537

    02/26/2020, 4:34 PM
    https://github.com/TomByrne/StarlingTextDisplay/tree/master/demo/src/ui/custom
  • b

    bright-gpu-74537

    02/26/2020, 4:34 PM
    oh yeah, that was it... subclassing all the components to add a "model" property
  • b

    bright-gpu-74537

    02/26/2020, 4:35 PM
    obvously that is something core could do... ill think about it, it could be useful... i still would have liked the @:bind macro to be able to have done something nifty here, but i dont see how it could of, as its not valid code to do:
  • b

    bright-gpu-74537

    02/26/2020, 4:36 PM
    @:bind(myComp.pos, _data.myProp)
  • b

    bright-gpu-74537

    02/26/2020, 4:36 PM
    ie, it needs a member var
1...183184185...1687Latest