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

    kind-policeman-40412

    07/30/2020, 2:09 AM
    In examples I only see how to call Logger.method static methods
  • k

    kind-policeman-40412

    07/30/2020, 2:10 AM
    I create a component using ComponentMacros.buildComponent("path_to_comp");
  • f

    fast-rain-20339

    07/30/2020, 2:10 AM
    I don't know if there's a cleaner solution, but the way I do it is have a
    setEditor(editor)
    in my XML component's haxe class. I use that to pass in the variable from a parent class, referring to my class by id.
  • f

    fast-rain-20339

    07/30/2020, 2:10 AM
    Ah
  • f

    fast-rain-20339

    07/30/2020, 2:11 AM
    Okay, yeah well it wouldn't work if you just build the component
  • f

    fast-rain-20339

    07/30/2020, 2:11 AM
    You'd need to extend the component as I always do, with a build macro.
  • f

    fast-rain-20339

    07/30/2020, 2:11 AM
    There may be a cleaner soln that I'm not aware of
  • f

    fast-rain-20339

    07/30/2020, 2:14 AM
    Hold on
  • f

    fast-rain-20339

    07/30/2020, 2:14 AM
    But if you do it your way, then you can just refer to the class things by ID
  • f

    fast-rain-20339

    07/30/2020, 2:14 AM
    and you're already in your code, not a class, so it shouldn't be a problem.
  • f

    fast-rain-20339

    07/30/2020, 2:15 AM
    Unless you're specifying onClick in the xml, in which case, don't 😆
  • k

    kind-policeman-40412

    07/30/2020, 2:15 AM
    I need to refer a runtime instance of the class so I call a method in some context. I mean the State(Screen) from which I instantiate a HaxeUI component.
  • k

    kind-policeman-40412

    07/30/2020, 2:16 AM
    But I think it's intended to be handled some other way with HaxeUI ))
  • k

    kind-policeman-40412

    07/30/2020, 2:17 AM
    As I don't see anything except
    params
    you can pass into ComponentMacros.buildComponent() which is unrelated to component context.
  • k

    kind-policeman-40412

    07/30/2020, 2:18 AM
    So writing a wrapper component is the only way to go?
  • k

    kind-policeman-40412

    07/30/2020, 2:18 AM
    I would like to avoid that extra code 🙂
  • k

    kind-policeman-40412

    07/30/2020, 2:28 AM
    Ok, what is a BindingManager class? Isn't it there to bind some variables to a component?
  • f

    fast-rain-20339

    07/30/2020, 2:40 AM
    Sorry, was afk grabbing lunch. I haven't used BindingManager before, so I can't help you there. I think you can do this super simply through ID's though, without a 'wrapper' class.
  • f

    fast-rain-20339

    07/30/2020, 2:40 AM
    buildComponent is generating the xml dynamically off the xml, which means that components with ID's can just be referred to as a property
  • f

    fast-rain-20339

    07/30/2020, 2:41 AM
    Copy code
    myXMLComponents = ComponentMacros.buildComponent(...)
    var a = 1
    myXMLComponents.theButtonID.onClick = function () { trace(a); };
  • k

    kind-policeman-40412

    07/30/2020, 2:42 AM
    No problem. I'm not in a hurry. You're very helpful 🙂
  • k

    kind-policeman-40412

    07/30/2020, 2:43 AM
    Hmm. Trying to wrap my head around ID's. I think I'm missing some context.
  • k

    kind-policeman-40412

    07/30/2020, 2:44 AM
    oh i see
  • f

    fast-rain-20339

    07/30/2020, 2:44 AM
    So if you xml file has a button that you want to refer to in haxe, just specify an ID attribute in the xml button
    <button id="theButtonID" text="My button that prints a" />
  • k

    kind-policeman-40412

    07/30/2020, 2:44 AM
    yeah. just figured out. thanks )
  • k

    kind-policeman-40412

    07/30/2020, 2:45 AM
    This actually looks like a viable solution.
  • k

    kind-policeman-40412

    07/30/2020, 3:11 AM
    Referring by ID does not work without wrapper component. The
    buildComponent
    method returns a Box instance which apparently does not have my
    joinButton
    property which results in
    Uncaught exception - Invalid field access : onClick
    on joinButton which is null.
  • f

    fast-rain-20339

    07/30/2020, 3:12 AM
    Hm, but
    joinButton
    appears in autocomplete?
  • k

    kind-policeman-40412

    07/30/2020, 3:13 AM
    I code in Vim and vaxe somehow does not autocomplete anything for me for some time. I just use it as is 🙂
  • f

    fast-rain-20339

    07/30/2020, 3:13 AM
    Ah yes, vaxe has given me my fair share of grief in the past. Gave up about a month ago and have been using vscode with the vim plugin 😆
1...322323324...1687Latest