input: Add focus_bordered method to toggle Input focus border. (#946)
This commit is contained in:
parent
a3a4f1942d
commit
6ea427549a
4 changed files with 30 additions and 6 deletions
|
|
@ -212,7 +212,11 @@ impl Render for Example {
|
||||||
.p_4()
|
.p_4()
|
||||||
.font_family("Monaco")
|
.font_family("Monaco")
|
||||||
.text_size(px(12.))
|
.text_size(px(12.))
|
||||||
.child(TextInput::new(&self.input_state).h_full()),
|
.child(
|
||||||
|
TextInput::new(&self.input_state)
|
||||||
|
.h_full()
|
||||||
|
.focus_bordered(false),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,12 @@ impl Render for Example {
|
||||||
.size_full()
|
.size_full()
|
||||||
.font_family("Menlo")
|
.font_family("Menlo")
|
||||||
.text_size(px(13.))
|
.text_size(px(13.))
|
||||||
.child(TextInput::new(&self.input_state).h_full().appearance(false)),
|
.child(
|
||||||
|
TextInput::new(&self.input_state)
|
||||||
|
.h_full()
|
||||||
|
.appearance(false)
|
||||||
|
.focus_bordered(false),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,12 @@ impl Render for Example {
|
||||||
.size_full()
|
.size_full()
|
||||||
.font_family("Monaco")
|
.font_family("Monaco")
|
||||||
.text_size(px(12.))
|
.text_size(px(12.))
|
||||||
.child(TextInput::new(&self.input_state).h_full().appearance(false)),
|
.child(
|
||||||
|
TextInput::new(&self.input_state)
|
||||||
|
.h_full()
|
||||||
|
.appearance(false)
|
||||||
|
.focus_bordered(false),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ pub struct TextInput {
|
||||||
mask_toggle: bool,
|
mask_toggle: bool,
|
||||||
disabled: bool,
|
disabled: bool,
|
||||||
bordered: bool,
|
bordered: bool,
|
||||||
|
focus_bordered: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sizable for TextInput {
|
impl Sizable for TextInput {
|
||||||
|
|
@ -48,10 +49,11 @@ impl TextInput {
|
||||||
suffix: None,
|
suffix: None,
|
||||||
height: None,
|
height: None,
|
||||||
appearance: true,
|
appearance: true,
|
||||||
bordered: true,
|
|
||||||
cleanable: false,
|
cleanable: false,
|
||||||
mask_toggle: false,
|
mask_toggle: false,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
bordered: true,
|
||||||
|
focus_bordered: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,12 +85,18 @@ impl TextInput {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the bordered for the input field, default: true
|
/// Set the bordered for the input, default: true
|
||||||
pub fn bordered(mut self, bordered: bool) -> Self {
|
pub fn bordered(mut self, bordered: bool) -> Self {
|
||||||
self.bordered = bordered;
|
self.bordered = bordered;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set focus border for the input, default is true.
|
||||||
|
pub fn focus_bordered(mut self, bordered: bool) -> Self {
|
||||||
|
self.focus_bordered = bordered;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Set true to show the clear button when the input field is not empty.
|
/// Set true to show the clear button when the input field is not empty.
|
||||||
pub fn cleanable(mut self) -> Self {
|
pub fn cleanable(mut self) -> Self {
|
||||||
self.cleanable = true;
|
self.cleanable = true;
|
||||||
|
|
@ -250,7 +258,9 @@ impl RenderOnce for TextInput {
|
||||||
this.border_color(cx.theme().input)
|
this.border_color(cx.theme().input)
|
||||||
.border_1()
|
.border_1()
|
||||||
.when(cx.theme().shadow, |this| this.shadow_sm())
|
.when(cx.theme().shadow, |this| this.shadow_sm())
|
||||||
.when(focused, |this| this.focused_border(cx))
|
.when(focused && self.focus_bordered, |this| {
|
||||||
|
this.focused_border(cx)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.when(prefix.is_none(), |this| this.input_pl(self.size))
|
.when(prefix.is_none(), |this| this.input_pl(self.size))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue