iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.94k stars 1.18k forks source link

Container::new() Docs #2057

Open AustinMReppert opened 1 year ago

AustinMReppert commented 1 year ago

Is there an existing issue for this?

Is this issue related to iced?

What happened?

https://docs.rs/iced/latest/iced/widget/struct.Container.html#method.new

States that new creates an empty container.

What is the expected behavior?

Should state that new creates a new container with a child element.

Version

master

Operating System

Windows

Do you have any log output?

No response

mschnell1 commented 10 months ago

I don't have an answer to this issue but a supposedly related question.

I checked out iced_table as an example for creating child widgets (i.e. container, column, and text in same). The example coming with iced_table nicely displays text in a grid. This done in a function cell() called in the standard view() function. But cell() does not provide a reference to the "application" (the "table" is an element of) and hence the business code I am going to write, which e.g. is supposed to modify the text to be displayed in any grid-cell, can't set what the individual cells will show. Of course I can use a "static mut" do provide this information, but this is unsafe, non idiomatic Rust and should be avoided. Moreover when using a lot of cells (or any large bunch objects), it does not make sense to assign a dedicated message to all of the contained widgets (e.g. buttons), but you would create them in a loop, and provide them with some kind of ID / handle. Unfortunately the Widgets force a dedicated type of message to be used (e.g. with a boolean parameter for Button), and don't allow for providing some kind of ID with the message. Again a "static mut" could help but.... What is the recommended way to create widgets that hold children and to create arrays of widgets ? Thanks for any pointers / explanations ! Thanks for listening, -Michael