https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • yeah, click will work for composites, but in wx they dont dispatch a click...
    b

    bright-gpu-74537

    04/02/2023, 4:22 PM
    yeah, click will work for composites, but in wx they dont dispatch a click...
  • (knocking up an example real quick)
    b

    bright-gpu-74537

    04/02/2023, 4:23 PM
    (knocking up an example real quick)
  • http://haxeui.org/builder/?9503d248
    b

    bright-gpu-74537

    04/02/2023, 4:25 PM
    http://haxeui.org/builder/?9503d248
  • this'll work on native also
    b

    bright-gpu-74537

    04/02/2023, 4:25 PM
    this'll work on native also
  • ill have a think about also allow click / selected to work with bind for individual items, i dont think it would be impossible to support - just because wx doesnt dispatch a click, doesnt mean haxeui cant (in response to a menu selection event for native). At least things are consistent that way
    b

    bright-gpu-74537

    04/02/2023, 4:26 PM
    ill have a think about also allow click / selected to work with bind for individual items, i dont think it would be impossible to support - just because wx doesnt dispatch a click, doesnt mean haxeui cant (in response to a menu selection event for native). At least things are consistent that way
  • what's the actual haxe code for that example?
    i

    icy-zebra-52882

    04/02/2023, 4:28 PM
    what's the actual haxe code for that example?
  • my current code is this, which afaik should be triggering: ```xml @:bind(openFileMenuItem, MenuEvent.MENU_SELECTED) private function openTextFile(e:haxe.ui.events.UIEvent) { trace('Attempting to open file dialogue'); Dialogs.openTextFile(LocaleManager.instance.lookupString("menu.file.openFile"),[{extension: ".txt", label: LocaleManager.instance.lookupString("menu.file.textFile")}], (info) -> { try { inputTextfield.text = info.text; } catch (e) { errorLabel.text = e.message; } }); } ```
    i

    icy-zebra-52882

    04/02/2023, 4:28 PM
    my current code is this, which afaik should be triggering:
    Copy code
    xml
    @:bind(openFileMenuItem, MenuEvent.MENU_SELECTED)
    private function openTextFile(e:haxe.ui.events.UIEvent) {
        trace('Attempting to open file dialogue');
        Dialogs.openTextFile(LocaleManager.instance.lookupString("menu.file.openFile"),[{extension: ".txt", label: LocaleManager.instance.lookupString("menu.file.textFile")}],
            (info) -> {
                try {
                    inputTextfield.text = info.text;
                } catch (e) {
                    errorLabel.text = e.message;
                }
            });
    }
  • you are binding to the menu item, not the menu bar
    b

    bright-gpu-74537

    04/02/2023, 4:29 PM
    you are binding to the menu item, not the menu bar
  • so how do you tell which menu item was pressed, do you have to `event.menuItem.id == myMenuItem.id`?
    i

    icy-zebra-52882

    04/02/2023, 4:31 PM
    so how do you tell which menu item was pressed, do you have to
    event.menuItem.id == myMenuItem.id
    ?
  • `switch (event.menuItem.id)` or something, then call a function
    b

    bright-gpu-74537

    04/02/2023, 4:31 PM
    switch (event.menuItem.id)
    or something, then call a function
  • ill try and unify it so you _can_ bind to menu items but a) im not 100% sure its gonna work and b) it wont be 10 mins
    b

    bright-gpu-74537

    04/02/2023, 4:32 PM
    ill try and unify it so you can bind to menu items but a) im not 100% sure its gonna work and b) it wont be 10 mins
  • I can work it that way, just didn't know which way to go about it
    i

    icy-zebra-52882

    04/02/2023, 4:33 PM
    I can work it that way, just didn't know which way to go about it
  • cheers for the help
    i

    icy-zebra-52882

    04/02/2023, 4:33 PM
    cheers for the help
  • yeah, there is defo a discrepency... technically, the way linked above is the "right" way to go about things, but actually, with composites you can get away with a few others ways (like click, etc)... so ill see about trying to get native menus to also work like that, but im not 100% sure as menus on native a totally different things to "other" components
    b

    bright-gpu-74537

    04/02/2023, 4:36 PM
    yeah, there is defo a discrepency... technically, the way linked above is the "right" way to go about things, but actually, with composites you can get away with a few others ways (like click, etc)... so ill see about trying to get native menus to also work like that, but im not 100% sure as menus on native a totally different things to "other" components
  • you also can't do something like ```haxe switch(e.menuItem.id) { case myMenuItem.id: { ... } }``` because it's not an allowed switch pattern
    i

    icy-zebra-52882

    04/02/2023, 4:37 PM
    you also can't do something like
    Copy code
    haxe
    switch(e.menuItem.id) {
      case myMenuItem.id: { ... }
    }
    because it's not an allowed switch pattern
  • at least it complained at me about it that way
    i

    icy-zebra-52882

    04/02/2023, 4:38 PM
    at least it complained at me about it that way
  • why would use you `myMenuItem.id`?
    b

    bright-gpu-74537

    04/02/2023, 4:38 PM
    why would use you
    myMenuItem.id
    ?
  • are the IDs of menu items a known pattern then?
    i

    icy-zebra-52882

    04/02/2023, 4:38 PM
    are the IDs of menu items a known pattern then?
  • why not just: ```haxe switch(e.menuItem.id) { case "id1": case "id2": ... } ```
    b

    bright-gpu-74537

    04/02/2023, 4:38 PM
    why not just:
    Copy code
    haxe
    switch(e.menuItem.id) {
      case "id1":
      case "id2":
      ...
    }
  • oh so it's not like a UUID then
    i

    icy-zebra-52882

    04/02/2023, 4:39 PM
    oh so it's not like a UUID then
  • well, the id if the menu item is something you assigned
    b

    bright-gpu-74537

    04/02/2023, 4:39 PM
    well, the id if the menu item is something you assigned
  • that does make sense, for some reason I assumed it was going off some internal id thing that was unique
    i

    icy-zebra-52882

    04/02/2023, 4:39 PM
    that does make sense, for some reason I assumed it was going off some internal id thing that was unique
  • probably from using LDtk
    i

    icy-zebra-52882

    04/02/2023, 4:40 PM
    probably from using LDtk
  • nope, the backend has to do some screwing around to match wx menu item int ids -> haxeui string ids, but from you perspective you'll get, for example "openFileMenuItem"
    b

    bright-gpu-74537

    04/02/2023, 4:40 PM
    nope, the backend has to do some screwing around to match wx menu item int ids -> haxeui string ids, but from you perspective you'll get, for example "openFileMenuItem"
  • woohoo, it works!!
    i

    icy-zebra-52882

    04/02/2023, 4:44 PM
    woohoo, it works!!
  • https://plzlookat.mystupid.pictures/explorer_H5IcPwFGsU.webm
    i

    icy-zebra-52882

    04/02/2023, 4:44 PM
    https://plzlookat.mystupid.pictures/explorer_H5IcPwFGsU.webm
  • the world of blocks will be culturally enriched
    i

    icy-zebra-52882

    04/02/2023, 4:45 PM
    the world of blocks will be culturally enriched
  • heh heh, i dont actually know what this is doing tbh... i mean, converting text into something "special" for pokemon?
    b

    bright-gpu-74537

    04/02/2023, 4:46 PM
    heh heh, i dont actually know what this is doing tbh... i mean, converting text into something "special" for pokemon?
  • nah it's for minecraft, you can create books which can be written (typed) into, and it lets you copy & paste - afterwards you can "sign" the book (adds your player name as the author), give it a title and block it from ever being edited again
    i

    icy-zebra-52882

    04/02/2023, 4:48 PM
    nah it's for minecraft, you can create books which can be written (typed) into, and it lets you copy & paste - afterwards you can "sign" the book (adds your player name as the author), give it a title and block it from ever being edited again
  • the books themselves have limits of pixels per line, lines per page
    i

    icy-zebra-52882

    04/02/2023, 4:49 PM
    the books themselves have limits of pixels per line, lines per page
1...161416151616...1687Latest