title: Layering Cocoa WebView - Drawing on top?
body: <p><a href="https://stackoverflow.com/questions/1618498/webview-in-core-animation-layer">webview in core animation layer</a></p>
  
  <p>The only other thread I can find is the above which doesn't necessarily fit my needs. Is there a reliable way to simply draw a view on top of a webview? I've tried to layer a regular NSView on top of WebView, and it draws right at first, but any movement in the webview (scrolling the page etc) appears to invalidate the view and produces visual artifacts.</p>
  
  <p>I've tried:</p>
  
  <pre><code>[[[NSApp mainWindow] contentView] addSubview:view positioned:NSWindowAbove relativeTo:webView];
  </code></pre>
  
  <p>No luck there, same problems -- z-ordering doesn't seem to work unless I'm missing something.</p>
  
  <p>Is this just a limitation of webviews?</p>
  
  <p>I also tried implementing the view above as a window, which worked much better (just controlled the location of the window programmatically). However, the desired behavior is for the user to enter some text into this window, but for it not to steal "focus" -- ie the main window goes inactive (the x - + go gray) when the user clicks on the text field in the new window. Any way to avoid that?</p>
  
  <p>I've tried subclassing NSWindow and overriding canBecomeKey (return YES) and canBecomeMain (return NO) but the window still steals focus.</p>
  
  <p>EDIT: I weep :-( I can't figure out a way around the drawing over webkit thing. I did, on the other hand, figure out a way to force the main window of my app to retain active state even though you have a popup window with key state. However, it has unintended consequences when using the text input on the popup dialog (which has to be forced into the key window state). Backspace doesn't work :: shakes head ::, and mouse events are not getting distributed to the webkit views below (for mouseovers on components embedded in the html). Craptacular.</p>
  
  <p>Josh</p>