diff options
author | 2022-02-12 17:21:28 +0700 | |
---|---|---|
committer | 2022-02-12 17:21:28 +0700 | |
commit | bd22cc0bc0f7551d29cf2acd22520f4a906f253c (patch) | |
tree | fae6435d0e1500204fca73fa7872fb99a41b6eb4 /pure/src/widget/text_input.rs | |
parent | e3108494e5886c34312184292ec05dddeb8bf3ca (diff) | |
download | iced-bd22cc0bc0f7551d29cf2acd22520f4a906f253c.tar.gz iced-bd22cc0bc0f7551d29cf2acd22520f4a906f253c.tar.bz2 iced-bd22cc0bc0f7551d29cf2acd22520f4a906f253c.zip |
Implement pure version of `todos` example :tada:
The `Widget` trait in `iced_pure` needed to change a bit to make the
implementation of `Element::map` possible.
Specifically, the `children` method has been split into `diff` and
`children_state`.
Diffstat (limited to 'pure/src/widget/text_input.rs')
-rw-r--r-- | pure/src/widget/text_input.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/pure/src/widget/text_input.rs b/pure/src/widget/text_input.rs index 06ab2910..e18a2bf0 100644 --- a/pure/src/widget/text_input.rs +++ b/pure/src/widget/text_input.rs @@ -146,8 +146,10 @@ where Box::new(text_input::State::new()) } - fn children(&self) -> &[Element<Message, Renderer>] { - &[] + fn diff(&self, _tree: &mut Tree) {} + + fn children_state(&self) -> Vec<Tree> { + Vec::new() } fn width(&self) -> Length { @@ -237,3 +239,16 @@ where text_input::mouse_interaction(layout, cursor_position) } } + +impl<'a, Message, Renderer> From<TextInput<'a, Message, Renderer>> + for Element<'a, Message, Renderer> +where + Message: 'a + Clone, + Renderer: 'a + text::Renderer, +{ + fn from( + text_input: TextInput<'a, Message, Renderer>, + ) -> Element<'a, Message, Renderer> { + Element::new(text_input) + } +} |