2

I have an embed webview in my cocoa application. However, the webview does not automatically take focus. I tried to do this with swift but it did not work:

override func viewDidAppear() {
    webView.window!.makeFirstResponder(webView)
}

what am I doing wrong. How can I make the webview taking the focus once the window is opened?

Borys Verebskyi
  • 4,160
  • 6
  • 28
  • 42
Pass
  • 1,501
  • 4
  • 21
  • 39
  • what on the webview are you hoping gets a first responder status? what are you looking for it to do? – Louis Tur Jan 06 '15 at 18:31
  • If you're talking about HTML-auto keyboard, check this answer: [How can I get a UIWebView to focus on a form input and bring up the keyboard?][1] [1]: http://stackoverflow.com/questions/4442811/how-can-i-get-a-uiwebview-to-focus-on-a-form-input-and-bring-up-the-keyboard?answertab=votes#tab-top – Vladimir Jan 06 '15 at 19:08
  • This is cocoa app. The webview holds an editable area, i.e the entire document is made editable. If I click on the view it will happy take the focus and I can start typing but it doesn't do that by default when I open the window. – Pass Jan 06 '15 at 19:47
  • did you try subclassing WebView and overriding acceptsFirstResponder to return YES – Cory Jan 06 '15 at 21:35
  • did that but did not work – Pass Jan 06 '15 at 21:57
  • @Pass I know this is really old, but I'm running into this same issue. Did you ever find a solution? – Clifton Labrum May 29 '20 at 20:22

0 Answers0