slint icon indicating copy to clipboard operation
slint copied to clipboard

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

Open ChronosWS opened this issue 1 year ago • 1 comments

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 avatar Nov 04 '23 21:11 ChronosWS

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.

ChronosWS avatar Nov 04 '23 21:11 ChronosWS