From 59cc8bf7e67b61b396643d9da61349504c270017 Mon Sep 17 00:00:00 2001 From: Sebastian Reinhard Date: Sun, 22 May 2022 16:08:39 +0200 Subject: [PATCH] Return whether or not editor key event was handled The host needs to know whether or not the plugin editor handles a given key event. Otherwise, the key event is sent to the host, and we don't receive a key up event. --- src/interfaces.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/interfaces.rs b/src/interfaces.rs index 6b5261e7..ee4caeb7 100644 --- a/src/interfaces.rs +++ b/src/interfaces.rs @@ -250,22 +250,24 @@ pub extern "C" fn dispatch( Ok(OpCode::EditorKeyDown) => { if let Some(ref mut editor) = get_editor() { if let Ok(key) = Key::try_from(value) { - editor.key_down(KeyCode { + let handled = editor.key_down(KeyCode { character: index as u8 as char, key, modifier: opt.to_bits() as u8, }); + return handled.into(); } } } Ok(OpCode::EditorKeyUp) => { if let Some(ref mut editor) = get_editor() { if let Ok(key) = Key::try_from(value) { - editor.key_up(KeyCode { + let handled = editor.key_up(KeyCode { character: index as u8 as char, key, modifier: opt.to_bits() as u8, }); + return handled.into(); } } }