* Fix Cmd-V typing v, suppress key_type on ctrl/logo, closes #432 Only send key_type() when modifiers are not pressed. * Fix backspace repeat and inserting ⌂, closes #476 Handle backspace in key_type instead of key_press, so we get auto-repeat for free, and can suppress typing the character.
This commit is contained in:
parent
4dd25de709
commit
0c65cc1e0d
|
@ -638,7 +638,7 @@ fn handle_window_event<T>(
|
|||
}
|
||||
|
||||
WindowEvent::ReceivedCharacter(codepoint) => {
|
||||
if !game.focused {
|
||||
if !game.focused && !game.is_ctrl_pressed && !game.is_logo_pressed {
|
||||
ui_container.key_type(game, codepoint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1537,9 +1537,6 @@ impl UIElement for TextBox {
|
|||
ctrl_pressed: bool,
|
||||
) {
|
||||
match (key, down) {
|
||||
(VirtualKeyCode::Back, _) => {
|
||||
self.input.pop();
|
||||
}
|
||||
(VirtualKeyCode::Return, false) => {
|
||||
use std::mem;
|
||||
let len = self.submit_funcs.len();
|
||||
|
@ -1564,6 +1561,12 @@ impl UIElement for TextBox {
|
|||
}
|
||||
|
||||
fn key_type(&mut self, _game: &mut crate::Game, c: char) {
|
||||
if c == '\x7f' || c == '\x08' {
|
||||
// Backspace
|
||||
self.input.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
self.input.push(c);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue