Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On macOS, remove doCommandBySelector in view #620

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/responder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tao": patch
---

On macOS, remove `doCommandBySelector` in view since this will block the key event to responder chain.

44 changes: 0 additions & 44 deletions src/platform_impl/macos/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ lazy_static! {
sel!(firstRectForCharacterRange:actualRange:),
first_rect_for_character_range as extern "C" fn(&Object, Sel, NSRange, *mut c_void) -> NSRect,
);
decl.add_method(
sel!(doCommandBySelector:),
do_command_by_selector as extern "C" fn(&Object, Sel, Sel),
);
decl.add_method(
sel!(keyDown:),
key_down as extern "C" fn(&mut Object, Sel, id),
Expand Down Expand Up @@ -573,46 +569,6 @@ extern "C" fn insert_text(this: &Object, _sel: Sel, string: id, _replacement_ran
trace!("Completed `insertText`");
}

extern "C" fn do_command_by_selector(_this: &Object, _sel: Sel, _command: Sel) {
trace!("Triggered `doCommandBySelector`");
// TODO: (Artur) all these inputs seem to trigger a key event with the correct text
// content so this is not needed anymore, it seems.

// Basically, we're sent this message whenever a keyboard event that doesn't generate a "human readable" character
// happens, i.e. newlines, tabs, and Ctrl+C.

// unsafe {
// let state_ptr: *mut c_void = *this.get_ivar("taoState");
// let state = &mut *(state_ptr as *mut ViewState);

// let mut events = VecDeque::with_capacity(1);
// if command == sel!(insertNewline:) {
// // The `else` condition would emit the same character, but I'm keeping this here both...
// // 1) as a reminder for how `doCommandBySelector` works
// // 2) to make our use of carriage return explicit
// events.push_back(EventWrapper::StaticEvent(Event::WindowEvent {
// window_id: WindowId(get_window_id(state.ns_window)),
// event: WindowEvent::ReceivedCharacter('\r'),
// }));
// } else {
// let raw_characters = state.raw_characters.take();
// if let Some(raw_characters) = raw_characters {
// for character in raw_characters
// .chars()
// .filter(|c| !is_corporate_character(*c))
// {
// events.push_back(EventWrapper::StaticEvent(Event::WindowEvent {
// window_id: WindowId(get_window_id(state.ns_window)),
// event: WindowEvent::ReceivedCharacter(character),
// }));
// }
// }
// };
// AppState::queue_events(events);
// }
trace!("Completed `doCommandBySelector`");
}

// Get characters
// fn get_characters(event: id, ignore_modifiers: bool) -> String {
// unsafe {
Expand Down