diff --git a/CHANGELOG.md b/CHANGELOG.md index 28ecbf83..ce16fb79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - **Breaking:** On Web, remove the `stdweb` backend. - Added `Window::focus_window`to bring the window to the front and set input focus. - On Wayland and X11, implement `is_maximized` method on `Window`. +- On macOS, fix issue where `ReceivedCharacter` was not being emitted during some key repeat events. # 0.25.0 (2021-05-15) diff --git a/src/platform_impl/macos/view.rs b/src/platform_impl/macos/view.rs index 360f289a..e44fd05b 100644 --- a/src/platform_impl/macos/view.rs +++ b/src/platform_impl/macos/view.rs @@ -55,7 +55,6 @@ pub(super) struct ViewState { pub cursor_state: Arc>, ime_spot: Option<(f64, f64)>, raw_characters: Option, - is_key_down: bool, pub(super) modifiers: ModifiersState, tracking_rect: Option, } @@ -74,7 +73,6 @@ pub fn new_view(ns_window: id) -> (IdRef, Weak>) { cursor_state, ime_spot: None, raw_characters: None, - is_key_down: false, modifiers: Default::default(), tracking_rect: None, }; @@ -516,7 +514,6 @@ extern "C" fn insert_text(this: &Object, _sel: Sel, string: id, _replacement_ran let slice = slice::from_raw_parts(characters.UTF8String() as *const c_uchar, characters.len()); let string = str::from_utf8_unchecked(slice); - state.is_key_down = true; // We don't need this now, but it's here if that changes. //let event: id = msg_send![NSApp(), currentEvent]; @@ -675,7 +672,7 @@ extern "C" fn key_down(this: &Object, _sel: Sel, event: id) { let pass_along = { AppState::queue_event(EventWrapper::StaticEvent(window_event)); // Emit `ReceivedCharacter` for key repeats - if is_repeat && state.is_key_down { + if is_repeat { for character in characters.chars().filter(|c| !is_corporate_character(*c)) { AppState::queue_event(EventWrapper::StaticEvent(Event::WindowEvent { window_id, @@ -705,8 +702,6 @@ extern "C" fn key_up(this: &Object, _sel: Sel, event: id) { let state_ptr: *mut c_void = *this.get_ivar("winitState"); let state = &mut *(state_ptr as *mut ViewState); - state.is_key_down = false; - let scancode = get_scancode(event) as u32; let virtual_keycode = retrieve_keycode(event);