On Sat, Nov 22, 2008 at 2:41 PM, Wolf Hauser <[EMAIL PROTECTED]> wrote: > Hello, > > Background: the application I am trying to build consists mainly of a > WebView. And I need to perform some custom drawing in front of that WebView. > First, I simply placed (in IB) a custom view in front of the WebView. > Unfortunately, my drawing always took place behind the WebView. A little > search in the documentation and on Google revealed that this is normal > behavior. The only way to draw in front of such a complex thing as a WebView > seems to be using Core Animation layer-backed views. OK. I set the > wantsLayer property to YES for the NSView that contains both the WebView and > my custom view. Then I set the zPosition of my custom view to 0.1 > (arbitrary, greater than zero). It works great, I finally see my drawing. > > However, now I have another problem: > Both, my custom view and the WebView are configured to resize with their > superview. Before activating wantsLayer, this resizing was a smooth process. > Now, however, some animations take place, fading my WebView in and out > constantly during the resize. I suspect that these are some implicit > transactions or whatever which come with Core Animation (I am totally new to > Core Animation). > > Question: is there a (simple) way to switch all these implicit behaviors off > (while keeping the possibility to stack the two views in layers)? > > Any suggestions would be very appreciated...
I don't believe your approach is viable. WebViews aren't supported in layer-backed mode. This is poorly documented, and the only place I could find it mentioned was in the AppKit release notes: http://developer.apple.com/releasenotes/Cocoa/AppKit.html It states: "Most of the standard views and controls that AppKit and Mac OS X's other Cocoa frameworks provide are able to function in layer-backed mode in Leopard, with the exception of certain specialized views such as WebKit WebViews and Quartz Composer QCViews, whose use in layer-backed mode is not presently supported." So you're out of luck there. However, for what you're doing you shouldn't need CoreAnimation at all, and certainly shouldn't need it for the WebView. Here are a few different things you could do: 1) Ditch the layers, and simply place your view in front of the WebView. Ignore the stuff you've been reading which says that overlapping views aren't supported; this is no longer true in Leopard. The reason it's not working for you is *probably* simply due to an Interface Builder bug where the actions of "Bring to Front" and "Send to Back" can become reversed. Try setting the order in code, or simply reversing the order of your views in IB. (Note that layering in this way can still fail in some ways, particularly if your WebView displays certain types of content, such as QuickTime movies, which end up being rendered in a special way that will display above your content.) 2) Use layer-backed mode only for your view, not the WebView. Layer-backed views draw above non-layer-backed views. 3) Use an overlay window. This is just a borderless window positioned in the correct place and added as a child window to your main window. Put the window in front, put whatever you want in the window. You'll have to manually manage resizing and such to work correctly, but this will give you the layering you seek without using CoreAnimation at all. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]