views:

119

answers:

3

By default, Cocoa adds a background blur effect to transparent and semitransparent modal sheets when they are applied to a window. I would like to disable the blur effect. How would I go about doing it?

I have created a custom sheet (a subclass of NSWindow with a transparent background and some controls in it). I am able to display it using the standard beginSheet method as follows:

[NSApp beginSheet:myCustomSheet
   modalForWindow:mainWindow
    modalDelegate:self
   didEndSelector:...];

The sheet displays fine, but everything behind it is blurred.

Note 1: I am writing a completely customized user interface for a touch screen / kiosk type app, so none of the usual Apple user interface guidelines apply.

Note 2: I do want to see what is underneath the sheet. As SirRatty pointed out, it is possible to block out the blurred portion by filling in the background. In my case, I want to have the background show through, just without appearing blurred.

+1  A: 

What I've done:

In IB, add a window-sized custom NSView to the window, at the bottom of the content view hierarchy. Set the object's class to MySolidView (or whatever.)

In Xcode, the MySolidView class does just one thing: on -drawRect it will fill the view with a solid color. (e.g. light grey).

SirRatty
I assume you are talking about adding this blanking view to the sheet, to block everything beneath it, thus negating the blur? If so, that's a reasonable solution, but I actually do want to have the background show through. Just not blurred. I'm picky `:)`
e.James
Oh, sorry, my bad. In that case, I can't help you. I don't know of any way to turn off that blurring (which I assume is a CoreImage effect).
SirRatty
It definitely looks as though it can't be modified without hacking around in the inner workings of AppKit. Thanks for taking the time to answer, though. I should probably have been more clear in the question.
e.James
+4  A: 

There's a private API call that can be used to set a CI filter on the background of a window:

http://www.mail-archive.com/[email protected]/msg16280.html

There's also a CGSRemoveWindowFilter:

extern CGError CGSRemoveWindowFilter(CGSConnectionID cid, CGSWindowID wid, CGSWindowFilterRef filter);

Just be aware that the usual private API caveats apply (might go away or change in the future, etc.).

Wevah
+1  A: 

You could write your own sheet animation routines that display your own NSWindow and fill the background of the window with a semitransparent colour. I'm not sure whether setAlphaValue: for NSWindow will also affect the child elements' opacity. If it does affect them, you could use setBackgroundColor: and provide the default window background colour but with an alpha component, this should not affect the child elements.

I suppose one of the problems of developing/designing your own user interface is when you have to reimplement the wheel just for a minor customisation. At least, if you write it yourself, you'll have more control over its customisation in the future.

dreamlax