0

My app allows user to navigate around a grid with the keyboard using all the arrow keys, enter and escape. The user can open and close items, including links. If the user opens a link to a webview, and the webview gain first responder, and the user is not editing inside an html input, I still want the user to be able navigate with the keyboard. So if the user pushes the left arrow key while reading a webpage I want the user to move left in the grid. Is it possible to detect this in any other way besides injecting JavaScript into each page that the webview loads? I know how to override NSWindow sendEvent or implement the WebEditingDelegate protocol but how to detect if the user is editing inside the webview?

John Wright
  • 2,418
  • 4
  • 29
  • 34

1 Answers1

0

Not sure how to detect if the user is editing inside the Webview without Javascript but it might not matter depending on your app. I notice that if the user is editing inside an html input field that sendEvent is not always called on NSWindow and the WebView swallows most events, except some keys like escape and return keys. So just override sendEvent and test if the firstResponder is the webview. If it is, you can redirect the key events you are interested in to your own event handler so that the webView doesn't swallow all these important events.

John Wright
  • 2,418
  • 4
  • 29
  • 34