forked from iced-rs/iced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
52 lines (44 loc) · 1.03 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use iced::{
widget::{container, text_input},
Element, Length, Sandbox, Settings,
};
fn main() -> iced::Result {
App::run(Settings::default())
}
pub struct App {
content: String,
}
#[derive(Debug, Clone)]
pub enum Message {
ContentChanged(String),
}
impl Sandbox for App {
type Message = Message;
fn new() -> Self {
Self {
content: "The first five digits of Pi are".into(),
}
}
fn title(&self) -> String {
String::from("buggy_text_selection")
}
fn update(&mut self, message: Message) {
match message {
Message::ContentChanged(text) => {
self.content = text;
}
}
}
fn view(&self) -> Element<Message> {
container(
text_input("placeholder", &self.content)
.on_input(Message::ContentChanged)
.width(Length::Fixed(200.0))
.size(25),
)
.width(Length::Fill)
.center_x()
.padding(50)
.into()
}
}