slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 602 forks source link

LineEdit/TextEdit only init `text` binding once from struct source #3848

Closed ChronosWS closed 2 months ago

ChronosWS commented 1 year ago

Windows 11/Rust 1.73/Slint 1.2.2

Given a component which has the following properties and children:

in-out property <ServerProfile> profile;

Text {
    text: "Name: \{profile.name}";
}

LineEdit { 
    text: profile.name;
    edited(val) => { profile.name = val }
}

If in code I update profile with a new ServerProfile, the text in the Text element will change, but the text in the LineEdit element will not. Even if I create a separate in-out property<string> name; and create a two-way binding from LineEdit.text to it and set the name property in code, the value of LineEdit.text remains unchanged.

Expected behavior:

LineEdit.text and TextEdit.text update their contents when the source of the one-way binding changes, exactly as it does for Text.text

Note:

This issue is not about the known issue where two-way bindings to struct fields does not work. In the application from which this issue comes, the user can successfully edit the profile name and its data is reflected in the profile property as expected, and can be extracted in code for further processing, as expected.

ChronosWS commented 1 year ago

Possibly related to https://github.com/slint-ui/slint/discussions/3108, but I think this is a legit bug worthy of tracking as an issue, not just a discussion item.

ogoffart commented 2 months ago

This is unfortunately not easy right now. But this is a duplicate of https://github.com/slint-ui/slint/issues/814 so marking it as such. Thanks anyway for the bug report.