5

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.

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.

Josh

4

1 回答 1

2

有点晚了,但我在同一个问题上撞了头,两年后我仍然找不到答案。就我而言,在我想在 WebView 上绘制的视图上设置 wantLayer=YES 解决了这个问题。

于 2013-05-15T02:20:11.893 回答