-
I've been looking into Slint a little bit, but haven't dug too deep yet. I have some crude sample programs, and recently have been trying to get a slightly more substantial test program going. I've been running into an issue that I haven't been able to work around, and was recently reminded to make a post here after seeing this post get made. I essentially am trying to figure out how to access some information about my view from my native Rust Code. Since the information being displayed requires monitoring these devices remotely I don't want to be polling them when the devices are not visible in the ScrollView. I couldn't find anyway to get this status from the ScrollView, but could easily calculate it as a property on my DeviceView. My issue however comes down to how to determine in my Rust code what it's on screen status is in the ScrollView? I've created a rough example of what I'm trying to do (using a ListView instead of a ScrollView) that can be seen here. Essentially right now when the rectangle goes half off the visible area of the ListView it's on_screen property changes from true to false. In this example it changes the color to green, but I need to be able to somehow access that on_screen state from Rust, to determine if I should be polling my devices over the network. Hope this makes sense. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
So one of the issues I was having trying to get it working with callbacks and the on_screen state in the device struct itself was how to call the callback when the state changes. I did a bit more digging, and changed my code to change the on_screen state using a pure callback.
I have some rust code to trigger on this callback, updated the appropriate device in the model, and then just return the boolean value passed into it. It's pretty hacky but it's the only thing I've managed to get to compile that seems like it could work. However my closure for the oscr_state callback never seems to get called. |
Beta Was this translation helpful? Give feedback.
-
One possible thing is to rely on the lazyness of properties. The Slint engine will, for example, only query the background property of a rectangle. So perhaps something like this:
Note that the oscr_state callback will have to be marked as pure (even if it is conceptually not pure) |
Beta Was this translation helpful? Give feedback.
One possible thing is to rely on the lazyness of properties. The Slint engine will, for example, only query the background property of a rectangle.
So perhaps something like this:
Note that the oscr_state callback will have to be marked as pure (even if it is conceptually not pure)