Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

items and element id's in for loops unaccessible to states #4891

Open
tyrsday29 opened this issue Mar 19, 2024 · 4 comments
Open

items and element id's in for loops unaccessible to states #4891

tyrsday29 opened this issue Mar 19, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@tyrsday29
Copy link

tyrsday29 commented Mar 19, 2024

Hey thanks for the great product! Super easy and enjoyable to use once you get the hang of it. But, I noticed that I can't access any items, or any element by its ID in for loops used by ListView, in states (when I was trying to implement a check all box). Not sure if this goes for all For Loops or just ones included in ListView, didn't go far enough into it, just thought I'd bring it to someone's attention!

For the record I tried using an element ID for ListView and several combinations to no avail.

@hunger
Copy link
Member

hunger commented Mar 20, 2024

A work-around could be a global: Put the property you need in there with a reasonable default value of course.

You can then access that globally to communicate from inside an if/for to the outside.

But yes, having a nice way of doing "use foo.bar if there is a foo right now else use some default value" would indeed be nice to have.

@hunger hunger added the enhancement New feature or request label Mar 20, 2024
@Areopagitics
Copy link

I second this as well.

I need to do something like this:

import {Palette, Button, VerticalBox , LineEdit, StandardListView, GroupBox, StandardTableView, ListView, CheckBox} from "std-widgets.slint";

export component AppWindow inherits Window {
    VerticalLayout {
        Button {
            text: "parent";
            clicked => { Child.test(); }
        }
        ListView {
            for i in 50 : Child := HorizontalLayout{
                height: 50px;
                function test() {
                    Child.height = 0px;
                }
                Button {
                    text: "child";
                    clicked => { Child.test(); }
                }
            }
        }
    }
}

@ogoffart
Copy link
Member

ogoffart commented Jun 4, 2024

@Areopagitics In your example, if I press on the "parent" button, then the test function of every children is called? But if I press on the "child" button, only the one for the current child is called.
We could make this work, but that seems unintuitive.

@Areopagitics
Copy link

@ogoffart Thank you for looking into this! Yes, that is correct, I am hoping to call all children from the parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants