From 846d1d8267cd886757006d970398de47ec5747ac Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Fri, 5 Mar 2021 13:30:53 -0500 Subject: [PATCH] Handle a bit more when simulating input This isn't great, but it adds tab/return/delete, which feels like the bare minimum; we can implement more as future work. --- druid-shell/src/text.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/druid-shell/src/text.rs b/druid-shell/src/text.rs index be475516b1..469db58b6a 100644 --- a/druid-shell/src/text.rs +++ b/druid-shell/src/text.rs @@ -450,6 +450,26 @@ pub fn simulate_input( input_handler.handle_action(Action::Move(movement)); } } + KbKey::Backspace => { + input_handler.handle_action(Action::Delete(Movement::Grapheme(Direction::Upstream))); + } + KbKey::Enter => { + // I'm sorry windows, you'll get IME soon. + input_handler.handle_action(Action::InsertNewLine { + ignore_hotkey: false, + newline_type: '\n', + }); + } + KbKey::Tab => { + let action = if event.mods.shift() { + Action::InsertBacktab + } else { + Action::InsertTab { + ignore_hotkey: false, + } + }; + input_handler.handle_action(action); + } _ => { handler.release_input_lock(token); return false;