Skip to content

Commit

Permalink
Handle a bit more when simulating input
Browse files Browse the repository at this point in the history
This isn't great, but it adds tab/return/delete, which feels
like the bare minimum; we can implement more as future work.
  • Loading branch information
cmyr committed Mar 8, 2021
1 parent 649f63a commit 648e403
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions druid-shell/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ pub fn simulate_input<H: WinHandler + ?Sized>(
event: KeyEvent,
) -> bool {
if handler.key_down(event.clone()) {
eprintln!("key handled, returning early");
return true;
}

Expand Down Expand Up @@ -450,6 +451,26 @@ pub fn simulate_input<H: WinHandler + ?Sized>(
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;
Expand Down

0 comments on commit 648e403

Please sign in to comment.