Skip to content

Commit

Permalink
On macOS, fix arrow keys misprint texts (#769)
Browse files Browse the repository at this point in the history
* On macOS, fix arrow keys misprint texts

* Update mod.rs
  • Loading branch information
wusyong authored Nov 25, 2022
1 parent 81818d7 commit 3005e54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/mac-arrow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"wry": patch
---

On macOS, fix arrow keys misprint text on textarea.

8 changes: 6 additions & 2 deletions src/webview/wkwebview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,12 @@ impl InnerWebView {
// So we pass the event to menu if we have one
extern "C" fn key_down(this: &mut Object, _: Sel, event: id) {
unsafe {
let superclass: *const Class = msg_send![this, superclass];
let () = msg_send![super(this, &*superclass), keyDown: event];
let keycode: u16 = msg_send![event, keyCode];
// Arrow keys are handled by other event chains
if !(123..=126).contains(&keycode) {
let superclass: *const Class = msg_send![this, superclass];
let () = msg_send![super(this, &*superclass), keyDown: event];
}

let app = cocoa::appkit::NSApp();
let menu: id = msg_send![app, mainMenu];
Expand Down

0 comments on commit 3005e54

Please sign in to comment.