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

    bright-gpu-74537

    08/07/2020, 11:10 AM
    ok, so i just knocked up a listview example in the end... scrollview would allow you to have items that "arent the same" in the same view, ill knock that up if you want, but probably list view is enough (assuming im understanding the q ofc)
  • b

    bright-gpu-74537

    08/07/2020, 11:11 AM
    Copy code
    xml
            <vbox>
                <button id="add1" text="Add" />
                <listview id="lv" width="400" height="300">
                    <item-renderer layoutName="horizontal" width="100%">
                        <label id="itemName" width="100%" verticalAlign="center" />
                        <button id="useButton" text="Use" />
                        <button id="dropButton" text="Drop" />
                    </item-renderer>
                </listview>
            </vbox>
  • b

    bright-gpu-74537

    08/07/2020, 11:11 AM
    Copy code
    haxe
                var lv = mainView.findComponent("lv", ListView);
                mainView.findComponent("add1", Button).onClick = function(e) {
                    lv.dataSource.add({ itemName: "some item #" + Std.random(100) });
                };
                lv.onComponentEvent = function(e) {
                    if (e.source.id == "dropButton") {
                        var itemToRemove = lv.dataSource.get(e.itemIndex);
                        lv.dataSource.remove(itemToRemove);
                    } else if (e.source.id == "useButton") {
                        Toolkit.messageBox("Use: " + lv.dataSource.get(e.itemIndex).itemName, "Use me!", MessageBoxType.TYPE_INFO);
                    }
                }
  • b

    bright-gpu-74537

    08/07/2020, 11:12 AM
    obivously this is using xml (but you could create the itemrenderer in code if you want) and its using ugly "findComponent" to glue it all together but if you have a custom component to display this you wouldnt need any of that
  • q

    quick-king-64105

    08/07/2020, 11:12 AM
    That's what I was trying to puzzle out - how does the item-renderer actually work here? Still reading over code, I know, I'm slow XD
  • b

    bright-gpu-74537

    08/07/2020, 11:12 AM
    oh, also, i added a little tweak to haxeui-core (adding itemIndex to the ComponentEvent) so you'll need latest git haxeui-core if you wanna actually use the code above
  • b

    bright-gpu-74537

    08/07/2020, 11:14 AM
    so basically, you when you add an itemrenderer to listview it stores it and all items in the listview will be a clone of that item with their data changed
  • q

    quick-king-64105

    08/07/2020, 11:14 AM
    Okay so what I gather is... listview has an underlying data source. Dynamic population happens via a templated system. ... The internal for item-renderer element there is the template?
  • q

    quick-king-64105

    08/07/2020, 11:14 AM
    Ah! I made the mistake of assuming
    item-renderer
    is specific. It is not. It is a generic.
  • q

    quick-king-64105

    08/07/2020, 11:15 AM
    IE; it is not specially made to display my items, it is the general object used to display items in a listview.
  • b

    bright-gpu-74537

    08/07/2020, 11:15 AM
    yeah, well, really its not just for listview... you can create an item renderer, add some children to it, and set its .data property
  • q

    quick-king-64105

    08/07/2020, 11:15 AM
    nods
  • b

    bright-gpu-74537

    08/07/2020, 11:16 AM
    and it will look through and match ids of components to items in the data and set their value property
  • q

    quick-king-64105

    08/07/2020, 11:16 AM
    I have to assume any unmatched components are just "whatever is in the templated version" then.
  • q

    quick-king-64105

    08/07/2020, 11:16 AM
    So... placeholders and defaults would be one and the same if I'm following that correctly.
  • b

    bright-gpu-74537

    08/07/2020, 11:17 AM
    basically, yeah
  • b

    bright-gpu-74537

    08/07/2020, 11:17 AM
    if you had this item renderer:
  • q

    quick-king-64105

    08/07/2020, 11:17 AM
    That's really cool. I'm not sure if that was here last time I was or not, but it's a really cool feature.
  • b

    bright-gpu-74537

    08/07/2020, 11:17 AM
    Copy code
    xml
                    <item-renderer layoutName="horizontal" width="100%">
                        <label id="itemName" width="100%" verticalAlign="center" />
                        <button id="useButton" text="Use" />
                        <button id="dropButton" text="Drop" />
                        <label id="BOBBY" text="default" />
                    </item-renderer>
  • b

    bright-gpu-74537

    08/07/2020, 11:18 AM
    and you didnt set a "BOBBY" on the item in the data source then it would show "default"
  • q

    quick-king-64105

    08/07/2020, 11:18 AM
    nodsnods
  • q

    quick-king-64105

    08/07/2020, 11:18 AM
    I think I'm following along.
  • q

    quick-king-64105

    08/07/2020, 11:18 AM
    But you know me XD I'll find some silly way to break it and be back sooner or later.
  • b

    bright-gpu-74537

    08/07/2020, 11:18 AM
    🙂
  • q

    quick-king-64105

    08/07/2020, 11:19 AM
    @User you'll appreciate yourself tagging yourself later.
  • b

    bright-gpu-74537

    08/07/2020, 11:19 AM
    breaking is good... means (generally) improvements
  • b

    bright-gpu-74537

    08/07/2020, 11:19 AM
    eg: adding the itemIndex to the component event.... tiny change, but useful
  • q

    quick-king-64105

    08/07/2020, 11:20 AM
    Still waiting for my host to leave Flash for HTML5. Are flash bugs even worth the time it takes anymore? Otherwise will just test HTML5 and then tell players they can blame the host.
  • b

    bright-gpu-74537

    08/07/2020, 11:20 AM
    lv.dataSource.get(e.itemIndex).itemName
    reads better than
    lv.dataSource.get(cast(e.target, ItemRenderer).itemIndex).itemName
    🙂
  • b

    bright-gpu-74537

    08/07/2020, 11:21 AM
    honestly, i havent test flash in ages... not sure if i even have a standalone player anymore
1...335336337...1687Latest