drop fat-fingered inputs after menu or dialog box close

This commit is contained in:
bunnie 2022-02-04 17:11:24 +08:00
parent 830d875911
commit c07101f41c
3 changed files with 10 additions and 40 deletions

View file

@ -452,26 +452,10 @@ fn xmain() -> ! {
}, },
Some(Opcode::KeyboardEvent) => msg_scalar_unpack!(msg, k1, k2, k3, k4, { Some(Opcode::KeyboardEvent) => msg_scalar_unpack!(msg, k1, k2, k3, k4, {
let keys = [ let keys = [
if let Some(a) = core::char::from_u32(k1 as u32) { core::char::from_u32(k1 as u32).unwrap_or('\u{0000}'),
a core::char::from_u32(k2 as u32).unwrap_or('\u{0000}'),
} else { core::char::from_u32(k3 as u32).unwrap_or('\u{0000}'),
'\u{0000}' core::char::from_u32(k4 as u32).unwrap_or('\u{0000}'),
},
if let Some(a) = core::char::from_u32(k2 as u32) {
a
} else {
'\u{0000}'
},
if let Some(a) = core::char::from_u32(k3 as u32) {
a
} else {
'\u{0000}'
},
if let Some(a) = core::char::from_u32(k4 as u32) {
a
} else {
'\u{0000}'
},
]; ];
context_mgr.key_event(keys, &gfx, &mut canvases); context_mgr.key_event(keys, &gfx, &mut canvases);
}), }),

View file

@ -298,6 +298,7 @@ impl<'a> Menu<'a> {
} }
self.index = 0; // reset the index to 0 self.index = 0; // reset the index to 0
self.gam.redraw().unwrap(); self.gam.redraw().unwrap();
break; // drop any characters that happened to trail the select key, it's probably a fat-finger error.
}, },
'←' => { '←' => {
// placeholder // placeholder
@ -414,26 +415,10 @@ pub fn menu_matic(items: Vec::<MenuItem>, menu_name: &'static str, maybe_manager
}, },
Some(MenuOpcode::Rawkeys) => xous::msg_scalar_unpack!(msg, k1, k2, k3, k4, { Some(MenuOpcode::Rawkeys) => xous::msg_scalar_unpack!(msg, k1, k2, k3, k4, {
let keys = [ let keys = [
if let Some(a) = core::char::from_u32(k1 as u32) { core::char::from_u32(k1 as u32).unwrap_or('\u{0000}'),
a core::char::from_u32(k2 as u32).unwrap_or('\u{0000}'),
} else { core::char::from_u32(k3 as u32).unwrap_or('\u{0000}'),
'\u{0000}' core::char::from_u32(k4 as u32).unwrap_or('\u{0000}'),
},
if let Some(a) = core::char::from_u32(k2 as u32) {
a
} else {
'\u{0000}'
},
if let Some(a) = core::char::from_u32(k3 as u32) {
a
} else {
'\u{0000}'
},
if let Some(a) = core::char::from_u32(k4 as u32) {
a
} else {
'\u{0000}'
},
]; ];
menu.lock().unwrap().key_event(keys); menu.lock().unwrap().key_event(keys);
}), }),

View file

@ -436,6 +436,7 @@ impl<'a> Modal<'a> {
log::debug!("closing modal"); log::debug!("closing modal");
// if it's a "close" button, invoke the GAM to put our box away // if it's a "close" button, invoke the GAM to put our box away
self.gam.relinquish_focus().unwrap(); self.gam.relinquish_focus().unwrap();
break; // don't process any more keys after a close message
} }
} }
} }