diff options
author | 2020-01-04 14:28:29 +0100 | |
---|---|---|
committer | 2020-01-04 14:28:29 +0100 | |
commit | 8311500ac03a95927022d8eec8178ba7d87b0010 (patch) | |
tree | 2423a758d4d639d22170b7dbc8413a246f448584 /web | |
parent | e4de2132e993ec6656da52063faf09bcfb978207 (diff) | |
parent | 43de28ae1515ace34758656f228444898459d85b (diff) | |
download | iced-8311500ac03a95927022d8eec8178ba7d87b0010.tar.gz iced-8311500ac03a95927022d8eec8178ba7d87b0010.tar.bz2 iced-8311500ac03a95927022d8eec8178ba7d87b0010.zip |
Merge pull request #141 from Songtronix/songtronix/progressbar-widget
Progress bar widget
Diffstat (limited to 'web')
-rw-r--r-- | web/src/widget/text_input.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/web/src/widget/text_input.rs b/web/src/widget/text_input.rs index 99792c84..eedc25bc 100644 --- a/web/src/widget/text_input.rs +++ b/web/src/widget/text_input.rs @@ -32,6 +32,7 @@ pub struct TextInput<'a, Message> { _state: &'a mut State, placeholder: String, value: String, + is_secure: bool, width: Length, max_width: Length, padding: u16, @@ -64,6 +65,7 @@ impl<'a, Message> TextInput<'a, Message> { _state: state, placeholder: String::from(placeholder), value: String::from(value), + is_secure: false, width: Length::Fill, max_width: Length::Shrink, padding: 0, @@ -73,6 +75,14 @@ impl<'a, Message> TextInput<'a, Message> { } } + /// Converts the [`TextInput`] into a secure password input. + /// + /// [`TextInput`]: struct.TextInput.html + pub fn password(mut self) -> Self { + self.is_secure = true; + self + } + /// Sets the width of the [`TextInput`]. /// /// [`TextInput`]: struct.TextInput.html @@ -161,6 +171,10 @@ where "value", bumpalo::format!(in bump, "{}", self.value).into_bump_str(), ) + .attr( + "type", + bumpalo::format!(in bump, "{}", if self.is_secure { "password" } else { "text" }).into_bump_str(), + ) .on("input", move |root, vdom, event| { let text_input = match event.target().and_then(|t| { t.dyn_into::<web_sys::HtmlInputElement>().ok() |