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

    clever-oil-61353

    05/19/2020, 4:20 AM
    forgot to add...... this is the code for that section i'm using....
  • c

    clever-oil-61353

    05/19/2020, 4:20 AM
    Toolkit.init(); var app = new HaxeUIApp(); app.ready(function() { var main:Component = ComponentMacros.buildComponent("Assets/style/main.xml"); app.addComponent(main); var menuBar = main.findComponent("displayAbout", MenuBar, null, "id" ); menuBar.onMenuSelected = function(e:MenuEvent) { switch (e.menuItem.id) { case "displayAbout": var dialog = new MyDialog(); dialog.onDialogClosed = function(e:DialogEvent) { trace("you clicked: " + e.button); } dialog.show(); } }
  • c

    clever-oil-61353

    05/19/2020, 4:23 AM
    if using just .... var menuBar = main.findComponentMacros.buildComponent(MenuBar); ...... it errors with MenuBar being null...... thats the reason i filled in the rest for it. Then it errors on the menuBar.onMenuSelected with that error i posted above.
  • c

    clever-oil-61353

    05/19/2020, 4:24 AM
    i get warnings about the lime syntax being deprecated, maybe if I update some of those it will help? i guess one way to find out.
  • c

    clever-oil-61353

    05/19/2020, 4:25 AM
    well, warnings about the __js___ being depricated and needing to use the js.Syntax...
  • c

    clever-oil-61353

    05/19/2020, 5:14 AM
    nice having those warnings gone. but, still no difference.
  • b

    bright-gpu-74537

    05/19/2020, 6:36 AM
    what does you main.xml look like?
  • b

    bright-gpu-74537

    05/19/2020, 6:37 AM
    Its likely you want findComponent to be recursive
  • b

    bright-gpu-74537

    05/19/2020, 6:38 AM
    it will default to recursive if a) you a looking by id and b) dont set it explicitly not to be recursive, so i think this should work:
  • b

    bright-gpu-74537

    05/19/2020, 6:38 AM
    var menuBar = main.findComponent("displayAbout", MenuBar);
  • b

    bright-gpu-74537

    05/19/2020, 6:38 AM
    if that doesnt work, i would double check there is a MenuBar component in that main.xml that does have an id of "displayAbout"
  • c

    clever-oil-61353

    05/19/2020, 6:55 AM
  • c

    clever-oil-61353

    05/19/2020, 6:56 AM
  • c

    clever-oil-61353

    05/19/2020, 6:56 AM
    the end of it
  • c

    clever-oil-61353

    05/19/2020, 7:02 AM
    attached displayAbout to the text of menu and have it as the text and id of About.... wanted to try a couple positions to see if it made a difference.
  • c

    clever-oil-61353

    05/19/2020, 7:03 AM
    wonder if i should try adding it to css and see if it can find it from there instead of id
  • c

    clever-oil-61353

    05/19/2020, 7:05 AM
    thats my main xml
  • c

    clever-oil-61353

    05/19/2020, 7:06 AM
    might look rough , havnt spend time to straighten anything
  • c

    clever-oil-61353

    05/19/2020, 7:07 AM
    nvm, its not as bad as i was thinking lol
  • c

    clever-oil-61353

    05/19/2020, 7:16 AM
    the main.hx file.... just ignore the testerbkup part.
  • c

    clever-oil-61353

    05/19/2020, 7:17 AM
    i use it to create the next one to modify stuff and test things to get this working.
  • c

    clever-oil-61353

    05/19/2020, 7:20 AM
    the public funtion its under happens to be the latest spot i'm testing it in.
  • c

    clever-oil-61353

    05/19/2020, 7:21 AM
    which seems to allow it to load quicker in the browser i noticed.
  • b

    bright-gpu-74537

    05/19/2020, 7:29 AM
    OK, so
    var menuBar = main.findComponent("displayAbout", MenuBar);
    is returning null because
    displayAbout
    is a
    Menu
    not a
    MenuBar
  • b

    bright-gpu-74537

    05/19/2020, 7:29 AM
    in fact, its both a
    Menu
    and a
    MenuItem
  • b

    bright-gpu-74537

    05/19/2020, 7:31 AM
    something like this would work (assuming you give your menu bar an ID):
  • b

    bright-gpu-74537

    05/19/2020, 7:31 AM
    Copy code
    haxe
    main.findComponent("mainMenu", MenuBar).onMenuSelected = function(e) {
        switch (e.menuItem.id) {
            case "displayAbout":
                ...
        }
    }
  • b

    bright-gpu-74537

    05/19/2020, 7:32 AM
    (on in your original xml its just a menu item, not a menu also, the "text='displayAbout'" confused me)
  • c

    clever-oil-61353

    05/19/2020, 7:33 AM
    yeah, been trying different things.
  • c

    clever-oil-61353

    05/19/2020, 7:38 AM
    that works!!
1...219220221...1687Latest