don't restore default text if field is cleared with backspace

even if persist is set, if the field has been edited, don't
restore the default text. otherwise, the default text re-appears
if you backspace to an empty string.
This commit is contained in:
bunnie 2022-11-30 15:15:56 +08:00
parent c8ec87b2d6
commit f0e1597b5c

View file

@ -490,11 +490,14 @@ impl ActionApi for TextEntry {
} }
} }
_ => { // text entry _ => { // text entry
self.keys_hit[self.selected_field as usize] = true; if !self.keys_hit[self.selected_field as usize]
if payload.placeholder_persist && payload.placeholder.is_some() && payload.content.len() == 0 { && payload.placeholder_persist
&& payload.placeholder.is_some()
&& payload.content.len() == 0 {
// copy the placeholder into the content string before processing the backspace // copy the placeholder into the content string before processing the backspace
payload.content.append(payload.placeholder.unwrap().to_str()).ok(); payload.content.append(payload.placeholder.unwrap().to_str()).ok();
} }
self.keys_hit[self.selected_field as usize] = true;
#[cfg(feature="tts")] #[cfg(feature="tts")]
{ {
let xns = xous_names::XousNames::new().unwrap(); let xns = xous_names::XousNames::new().unwrap();