Layering Cocoa WebView - Drawing on top?

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2010-05-18T20:57:03Z Indexed on 2010/05/18 21:00 UTC
Read the original article Hit count: 343

Filed under:
|
|
|
|

http://stackoverflow.com/questions/1618498/webview-in-core-animation-layer

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.

I've tried:

[[[NSApp mainWindow] contentView] addSubview:view positioned:NSWindowAbove relativeTo:webView];

No luck there, same problems -- z-ordering doesn't seem to work unless I'm missing something.

Is this just a limitation of webviews?

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?

I've tried subclassing NSWindow and overriding canBecomeKey (return YES) and canBecomeMain (return NO) but the window still steals focus.

Josh

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about nswindow