Simplify type signature of TextInput methods
This commit is contained in:
parent
827ba5b16c
commit
09174d5a25
1 changed files with 11 additions and 21 deletions
|
|
@ -129,11 +129,11 @@ 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
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,14 +141,11 @@ where
|
||||||
/// the [`TextInput`], if `Some`.
|
/// the [`TextInput`], if `Some`.
|
||||||
///
|
///
|
||||||
/// If `None`, the [`TextInput`] will be disabled.
|
/// If `None`, the [`TextInput`] will be disabled.
|
||||||
pub fn on_input_maybe<F>(mut self, callback: Option<F>) -> Self
|
pub fn on_input_maybe(
|
||||||
where
|
mut self,
|
||||||
F: 'a + Fn(String) -> Message,
|
on_input: Option<impl Fn(String) -> Message + 'a>,
|
||||||
{
|
) -> Self {
|
||||||
self.on_input = match callback {
|
self.on_input = on_input.map(|f| Box::new(f) as _);
|
||||||
Some(c) => Some(Box::new(c)),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,8 +158,6 @@ where
|
||||||
|
|
||||||
/// Sets the message that should be produced when the [`TextInput`] is
|
/// Sets the message that should be produced when the [`TextInput`] is
|
||||||
/// focused and the enter key is pressed, if `Some`.
|
/// focused and the enter key is pressed, if `Some`.
|
||||||
///
|
|
||||||
/// If `None` the [`TextInput`] nothing will happen.
|
|
||||||
pub fn on_submit_maybe(mut self, on_submit: Option<Message>) -> Self {
|
pub fn on_submit_maybe(mut self, on_submit: Option<Message>) -> Self {
|
||||||
self.on_submit = on_submit;
|
self.on_submit = on_submit;
|
||||||
self
|
self
|
||||||
|
|
@ -180,16 +175,11 @@ where
|
||||||
|
|
||||||
/// 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`], if `Some`.
|
/// the [`TextInput`], if `Some`.
|
||||||
///
|
|
||||||
/// If `None` nothing will happen.
|
|
||||||
pub fn on_paste_maybe(
|
pub fn on_paste_maybe(
|
||||||
mut self,
|
mut self,
|
||||||
on_paste: Option<impl Fn(String) -> Message + 'a>,
|
on_paste: Option<impl Fn(String) -> Message + 'a>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.on_paste = match on_paste {
|
self.on_paste = on_paste.map(|f| Box::new(f) as _);
|
||||||
Some(func) => Some(Box::new(func)),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue