Function cosmic::iced::widget::text_input
source · pub fn text_input<'a, Message, Theme, Renderer>(
placeholder: &str,
value: &str,
) -> TextInput<'a, Message, Theme, Renderer>
Expand description
Creates a new TextInput
.
Text inputs display fields that can be filled with text.
§Example
use iced::widget::text_input;
struct State {
content: String,
}
#[derive(Debug, Clone)]
enum Message {
ContentChanged(String)
}
fn view(state: &State) -> Element<'_, Message> {
text_input("Type something here...", &state.content)
.on_input(Message::ContentChanged)
.into()
}
fn update(state: &mut State, message: Message) {
match message {
Message::ContentChanged(content) => {
state.content = content;
}
}
}