From 44b15c72627b49e015e599a6f5ea07db9ab533e0 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 22 Jun 2022 21:41:07 +0800 Subject: [PATCH] modify text entry behavior to recover default if the field is empty and you're not in password mode, pressing left or right will populate the autocomplete field --- services/gam/src/modal/textentry.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/services/gam/src/modal/textentry.rs b/services/gam/src/modal/textentry.rs index 662fd387a..2b2ef3935 100644 --- a/services/gam/src/modal/textentry.rs +++ b/services/gam/src/modal/textentry.rs @@ -368,7 +368,7 @@ impl ActionApi for TextEntry { log::trace!("key_action: {}", k); match k { '←' => { - if self.visibility as u32 > 0 { + if (self.visibility as u32 > 0) && self.is_password { match FromPrimitive::from_u32(self.visibility as u32 - 1) { Some(new_visibility) => { log::trace!("new visibility: {:?}", new_visibility); @@ -378,10 +378,17 @@ impl ActionApi for TextEntry { panic!("internal error: an TextEntryVisibility did not resolve correctly"); } } + } else if !self.is_password { + if payload.content.len() == 0 { + if let Some(placeholder) = payload.placeholder { + payload.content.append(placeholder.to_str()).ok(); + } + } } }, '→' => { - if (self.visibility as u32) < (TextEntryVisibility::Hidden as u32) { + if ((self.visibility as u32) < (TextEntryVisibility::Hidden as u32)) + && self.is_password { match FromPrimitive::from_u32(self.visibility as u32 + 1) { Some(new_visibility) => { log::trace!("new visibility: {:?}", new_visibility); @@ -391,6 +398,12 @@ impl ActionApi for TextEntry { panic!("internal error: an TextEntryVisibility did not resolve correctly"); } } + } else if !self.is_password { + if payload.content.len() == 0 { + if let Some(placeholder) = payload.placeholder { + payload.content.append(placeholder.to_str()).ok(); + } + } } }, '∴' | '\u{d}' => {