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

    bright-gpu-74537

    01/14/2023, 12:06 PM
    then you just go
    var d = new CustomDialog(); d.show();
  • r

    refined-greece-48002

    01/14/2023, 12:06 PM
    This is a minimalized repro, but the way this came up in my project is I have larger UI elements with multiple dialogs in them (all hidden), which represent one flow of modals... and the crash occurs when I want to unload one modal flow and load another with another set of dialogs
  • r

    refined-greece-48002

    01/14/2023, 12:06 PM
    I'm guessing that is just wrong in general though 😄
  • b

    bright-gpu-74537

    01/14/2023, 12:07 PM
    i think the main issues are a) your dialog isnt really a dialog, its a vbox with a dialog embedded in it and b) you are manually adding the dialog to the screen, and thats what haxeui will do
  • r

    refined-greece-48002

    01/14/2023, 12:07 PM
    Got it, I will switch to doing that, and I guess break the dialogs into individual xml files... how do you unload the dialog when it's no longer needed, though?
  • r

    refined-greece-48002

    01/14/2023, 12:07 PM
    (if I want to force it to go away permanetly but not because of a specific user interaction, like a timed dialog)
  • b

    bright-gpu-74537

    01/14/2023, 12:08 PM
    dialog.hide()
  • r

    refined-greece-48002

    01/14/2023, 12:08 PM
    ah this actually removes it from the tree? nice
  • r

    refined-greece-48002

    01/14/2023, 12:08 PM
    thank you!
  • b

    bright-gpu-74537

    01/14/2023, 12:08 PM
    yeah, and it will destroy the dialog, if you didnt want it to be destroyed, you can set
    dialog.destroyOnClose = false
  • r

    refined-greece-48002

    01/14/2023, 12:08 PM
    perfect
  • b

    bright-gpu-74537

    01/14/2023, 12:09 PM
    you can also do
    dialog.hideDialog(DialogButton.X)
    ... this is useful if you have a validation override that will stop the dialog from closing
  • b

    bright-gpu-74537

    01/14/2023, 12:10 PM
    dialog.hide
    is basically just
    dialog.hideDialog(DialogButton.CLOSE)
  • b

    bright-gpu-74537

    01/14/2023, 12:12 PM
    btw, another fyi: you can use
    @:xml
    in custom components (at the top of the class), for dialogs (which tend to be pretty small xml wise) i find it really useful, eg:
  • b

    bright-gpu-74537

    01/14/2023, 12:13 PM
    Copy code
    haxe
    @:xml('
        <dialog id="dlg" width="30%" height="30%" visible="false">
            <button id="btn"/>
        </dialog>
    ')
    class CustomDialog extends Dialog {
    }
  • b

    bright-gpu-74537

    01/14/2023, 12:13 PM
    (obviously you dont have to use that, but for tiny little UIs, which dialogs tend to be, i find it much neater)
  • r

    refined-greece-48002

    01/14/2023, 12:13 PM
    that is handy! though some of mine in this particular case are fairly complex custom dialogs
  • b

    bright-gpu-74537

    01/14/2023, 12:14 PM
    cool, fair enough
  • b

    bright-gpu-74537

    01/14/2023, 12:14 PM
    another fyi... 🙂 You ca also now put the .xml next to the class
  • r

    refined-greece-48002

    01/14/2023, 12:14 PM
    how does that work?
  • b

    bright-gpu-74537

    01/14/2023, 12:15 PM
    so you can have your
    dialog.xml
    in the same dir as your class and just use
    @:build(haxe.ui.macros.ComponentMacros.build("dialog.xml"))
  • r

    refined-greece-48002

    01/14/2023, 12:15 PM
    aaah I see what you mean, neat
  • b

    bright-gpu-74537

    01/14/2023, 12:15 PM
    just little QoL things that can let you organize things differently if you want
  • b

    bright-gpu-74537

    01/14/2023, 12:16 PM
    (all optional / up to you ofc)
  • r

    refined-greece-48002

    01/14/2023, 12:16 PM
    always happy about more QoL 🙂
  • b

    bright-gpu-74537

    01/14/2023, 12:17 PM
    @:build(haxe.ui.macros.ComponentMacros.build("..."))
    should probably be
    @:build(haxe.ui.ComponentBuilder.build("..."))
    btw, doesnt make a difference at the moment (its just an alias) but it is the preferred method (in case the other does get removed)
  • r

    refined-greece-48002

    01/14/2023, 12:18 PM
    I will update that! I think I've just been using the same snippet to set up my UI classes since the first time I got it working
  • b

    bright-gpu-74537

    01/14/2023, 12:19 PM
    yeah, i think the old method is also used all over the place in docs and examples - it doesnt really matter, its just to unify
    haxe.ui.ComponentBuilder
    and
    haxe.ui.RuntimeComponentBuilder
  • b

    bright-gpu-74537

    01/14/2023, 12:19 PM
    well, not unify, but make consistent
  • r

    refined-greece-48002

    01/14/2023, 2:23 PM
    Hmm, @bright-gpu-74537 , what about in this case? https://gist.github.com/kaug-whis/3c6a6a784aa3ab6e287fa1c04ea14fc6 This generates the same crash.
1...137313741375...1687Latest