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

    bright-gpu-74537

    12/23/2022, 4:19 PM
    Copy code
    haxe
                var d = new MyDialog();
                d.onDialogClosed = function(e:DialogEvent) {
                    trace(e.button);
                }
                d.show();
  • b

    bright-gpu-74537

    12/23/2022, 4:20 PM
    > I did a handler to dispatch a dialog closed event when you have wx_CLOSE_WINDOW not sure what you mean here
  • b

    bright-gpu-74537

    12/23/2022, 4:20 PM
    you shouldnt need to mess with wx events
  • b

    bright-gpu-74537

    12/23/2022, 4:21 PM
    if you want to close the dialog manually, like with a button (that isnt in the footer - as they will auto close it - unless you override
    validateDialog
    )... you can just do "hideDialog" or "hide"
  • b

    bright-gpu-74537

    12/23/2022, 4:21 PM
    at least i think you can
  • b

    bright-gpu-74537

    12/23/2022, 4:23 PM
    yeah, this seems fine:
  • b

    bright-gpu-74537

    12/23/2022, 4:23 PM
    Copy code
    haxe
    @:xml('
        <dialog title="My Dialog" width="300" height="300">
            <vbox width="100%" height="100%">
                <button id="closeDialog" text="Close Dialog" />
                <button id="closeDialog2" text="Close Dialog2" />
                <button text="Some Dialog" />
                <button text="100% x 100%" width="100%" height="100%" />
            </vbox>
        </dialog>
    ')
    class MyDialog extends Dialog {
        public function new() {
            super();
            buttons = DialogButton.OK | "Custom";
            closeDialog.onClick = (_) -> {
                this.hideDialog("bob");
            }
            closeDialog2.onClick = (_) -> {
                this.hide();
            }
        }
    }
  • f

    full-journalist-82607

    12/23/2022, 4:25 PM
    Oh it seems fine. One moment
  • f

    full-journalist-82607

    12/23/2022, 4:29 PM
    Actually, it always worked. I was stupid, I actually set the onDialogClosed() after showing the dialog 😊 which works on html5 but not on hxwidgets.
  • b

    bright-gpu-74537

    12/23/2022, 4:30 PM
    yeah, dialogs are modal by default (and in hxcpp / wx that also means synchronous), it would have probably been fine if it were a modaless dialog
  • b

    bright-gpu-74537

    12/23/2022, 4:31 PM
    yeah, this is fine:
  • b

    bright-gpu-74537

    12/23/2022, 4:31 PM
    Copy code
    haxe
                var d = new MyDialog();
                d.modal = false;
                d.show();
                d.onDialogClosed = function(e:DialogEvent) {
                    trace(e.button);
                }
  • b

    bright-gpu-74537

    12/23/2022, 4:32 PM
    because, in this case, show() isnt blocking
  • f

    full-journalist-82607

    12/23/2022, 4:36 PM
    Humm interesting, in this case it works indeed. But if I do showDialog() it doesn't.
  • b

    bright-gpu-74537

    12/23/2022, 4:37 PM
    because:
  • b

    bright-gpu-74537

    12/23/2022, 4:37 PM
    Copy code
    haxe
        public function showDialog(modal:Bool = true) {
            this.modal = modal;
            show();
        }
  • b

    bright-gpu-74537

    12/23/2022, 4:37 PM
    itll be overwriting the previous .modal
  • b

    bright-gpu-74537

    12/23/2022, 4:38 PM
    either way, its better practice to setup your event handlers before you make a call that might dispatch them
  • f

    full-journalist-82607

    12/23/2022, 4:46 PM
    I agree with you, usually I do this. But it wasn't the case here ( and I didn't notice it) 🙂 Thanks for everything. I think I have now every part of the app I was testing working and not crashing. 🙂
  • b

    bright-gpu-74537

    12/23/2022, 4:46 PM
    🥳
  • b

    bright-gpu-74537

    12/23/2022, 4:47 PM
    ... ... some nice catches there too - so thank you 🙂
  • f

    full-journalist-82607

    12/23/2022, 4:48 PM
  • s

    some-family-49805

    12/23/2022, 11:48 PM
    I just checked - HaxeUI looks really good!
  • h

    hallowed-ocean-84954

    12/24/2022, 12:07 AM
    Yep
  • h

    hallowed-ocean-84954

    12/24/2022, 3:58 AM
    Had a bit more of a look. This is really odd. It isn't even processing an element related to PointLight when it throws this error. There error is coming from L356 in the Macros.hx:
    Copy code
    builder.addGetter(f.name, f.type, macro {
                    var c = findComponent($v{variable}, $componentTypeExpr);
                    if (c == null) {
                        trace("WARNING: no child component found: " + $v{variable});
                        return haxe.ui.util.Variant.fromDynamic(null);    <------- fails here
                    }
    I add some debug and it's processing descriptionId which is a Label in the reference-library. But when it finds c is null here it is trying to return a Variant where it must be expecting a PointLight. I have now idea how it ended up confusing the too. But I'm not good with macros so while I'm guessing findComponent has probably failed I really don't know where to go from here. I've tried making ids more unique in the point-light xml but no difference.
  • b

    bright-gpu-74537

    12/24/2022, 7:39 AM
    ok, so just to fully understand, you have a custom component, that has a property that isnt an intrinsic type, and then you are trying to bind that property in another component / view that has a instance of the original custom component, right?
  • b

    bright-gpu-74537

    12/24/2022, 8:17 AM
    OK, so i dont know if it'll fix your issue, but ive simplified variable binding in general - so all of that code you listed doesnt exist anymore - findComponent was never needed since we already have a typed member variable at that point, also i tried this, and it seems fine:
  • b

    bright-gpu-74537

    12/24/2022, 8:17 AM
    Copy code
    @:build(haxe.ui.ComponentBuilder.build("main-view.xml"))
    class MainView extends VBox {
        @:bind(this.text) var thisText:String = "tim";
        @:bind(comp1.text) var comp1Text:String = "tim";
        @:bind(comp2.buttonText) var comp2ButtonText:String = "jimmy";
        @:bind(comp2.someObject) var comp2SomeObject:SomeObject = {a: "AAAA", b: "BBBB"};
    }
  • b

    bright-gpu-74537

    12/24/2022, 8:18 AM
    Copy code
    @:xml('
    <vbox>
        <button id="theButton" text="Button" />
        <label id="theLabel" text="Label" />
    </vbox>
    ')
    class SomeComponent extends VBox {
        public var buttonText(get, set):String;
        private function get_buttonText():String {
            return theButton.text;
        }
        private function set_buttonText(value:String):String {
            theButton.text = value;
            return value;
        }
    
        public var someObject(get, set):SomeObject;
        private function get_someObject():SomeObject {
            var parts = theLabel.text.split("-");
            return {
                a: StringTools.trim(parts[0]),
                b: StringTools.trim(parts[1]),
            }
        }
        private function set_someObject(value:SomeObject):SomeObject {
            theLabel.text = value.a + " - " + value.b;
            return value;
        }
    }
  • b

    bright-gpu-74537

    12/24/2022, 8:18 AM
    Copy code
    haxe
    typedef SomeObject = {
        var a:String;
        var b:String;
    }
1...135113521353...1687Latest