summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-05 22:03:32 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-01-05 22:03:32 +0100
commitbbc8f837d72b9bc5f6a0b3125b54c246fb3b2b94 (patch)
tree749e2b339ca8ca08a6f5d28befc6a3f137fc2d01 /web
parenta848306b89053ef4ba2aeb4eb7899bec94d93cb3 (diff)
parent8311500ac03a95927022d8eec8178ba7d87b0010 (diff)
downloadiced-bbc8f837d72b9bc5f6a0b3125b54c246fb3b2b94.tar.gz
iced-bbc8f837d72b9bc5f6a0b3125b54c246fb3b2b94.tar.bz2
iced-bbc8f837d72b9bc5f6a0b3125b54c246fb3b2b94.zip
Merge branch 'master' into feature/custom-styling
Diffstat (limited to 'web')
-rw-r--r--web/src/widget/text_input.rs14
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()