commit
dff14bd440
1 changed files with 34 additions and 5 deletions
|
|
@ -129,11 +129,23 @@ where
|
||||||
/// the [`TextInput`].
|
/// the [`TextInput`].
|
||||||
///
|
///
|
||||||
/// If this method is not called, the [`TextInput`] will be disabled.
|
/// If this method is not called, the [`TextInput`] will be disabled.
|
||||||
pub fn on_input<F>(mut self, callback: F) -> Self
|
pub fn on_input(
|
||||||
where
|
mut self,
|
||||||
F: 'a + Fn(String) -> Message,
|
on_input: impl Fn(String) -> Message + 'a,
|
||||||
{
|
) -> Self {
|
||||||
self.on_input = Some(Box::new(callback));
|
self.on_input = Some(Box::new(on_input));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the message that should be produced when some text is typed into
|
||||||
|
/// the [`TextInput`], if `Some`.
|
||||||
|
///
|
||||||
|
/// If `None`, the [`TextInput`] will be disabled.
|
||||||
|
pub fn on_input_maybe(
|
||||||
|
mut self,
|
||||||
|
on_input: Option<impl Fn(String) -> Message + 'a>,
|
||||||
|
) -> Self {
|
||||||
|
self.on_input = on_input.map(|f| Box::new(f) as _);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +156,13 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the message that should be produced when the [`TextInput`] is
|
||||||
|
/// focused and the enter key is pressed, if `Some`.
|
||||||
|
pub fn on_submit_maybe(mut self, on_submit: Option<Message>) -> Self {
|
||||||
|
self.on_submit = on_submit;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the message that should be produced when some text is pasted into
|
/// Sets the message that should be produced when some text is pasted into
|
||||||
/// the [`TextInput`].
|
/// the [`TextInput`].
|
||||||
pub fn on_paste(
|
pub fn on_paste(
|
||||||
|
|
@ -154,6 +173,16 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the message that should be produced when some text is pasted into
|
||||||
|
/// the [`TextInput`], if `Some`.
|
||||||
|
pub fn on_paste_maybe(
|
||||||
|
mut self,
|
||||||
|
on_paste: Option<impl Fn(String) -> Message + 'a>,
|
||||||
|
) -> Self {
|
||||||
|
self.on_paste = on_paste.map(|f| Box::new(f) as _);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the [`Font`] of the [`TextInput`].
|
/// Sets the [`Font`] of the [`TextInput`].
|
||||||
///
|
///
|
||||||
/// [`Font`]: text::Renderer::Font
|
/// [`Font`]: text::Renderer::Font
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue