summaryrefslogtreecommitdiffstats
path: root/pure/src/widget/text_input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'pure/src/widget/text_input.rs')
-rw-r--r--pure/src/widget/text_input.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/pure/src/widget/text_input.rs b/pure/src/widget/text_input.rs
index 9b0a466a..514a6795 100644
--- a/pure/src/widget/text_input.rs
+++ b/pure/src/widget/text_input.rs
@@ -46,6 +46,7 @@ where
padding: Padding,
size: Option<u16>,
on_change: Box<dyn Fn(String) -> Message + 'a>,
+ on_paste: Option<Box<dyn Fn(String) -> Message + 'a>>,
on_submit: Option<Message>,
style: <Renderer::Theme as StyleSheet>::Style,
}
@@ -75,6 +76,7 @@ where
padding: Padding::ZERO,
size: None,
on_change: Box::new(on_change),
+ on_paste: None,
on_submit: None,
style: Default::default(),
}
@@ -86,6 +88,16 @@ where
self
}
+ /// Sets the message that should be produced when some text is pasted into
+ /// the [`TextInput`].
+ pub fn on_paste(
+ mut self,
+ on_paste: impl Fn(String) -> Message + 'a,
+ ) -> Self {
+ self.on_paste = Some(Box::new(on_paste));
+ self
+ }
+
/// Sets the [`Font`] of the [`TextInput`].
///
/// [`Font`]: text::Renderer::Font
@@ -215,6 +227,7 @@ where
&self.font,
self.is_secure,
self.on_change.as_ref(),
+ self.on_paste.as_deref(),
&self.on_submit,
|| tree.state.downcast_mut::<text_input::State>(),
)