views:

33

answers:

2

I would like to disable the animation that Cocoa performs when displaying a modal sheet.

Apple's Sheet Programming Guide states:

... Other sheet behavior, such as the animation when it appears and is dismissed, is handled automatically by the Application Kit.

But it doesn't provide any hints on how to disable this effect.

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 it goes through an animation when it appears, and again when it closes.

Note: 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.

A: 

This is a wild guess (I'm too lazy to try it) but the animation might be handled using Core Animation. If so, you might be able to do this:

[CATransaction begin];
[CATransaction setValue: [NSNumber numberWithBool: YES]
    forKey: kCATransactionDisableActions ];
[NSApp beginSheet:myCustomSheet
   modalForWindow:mainWindow
    modalDelegate:self
   didEndSelector:...];
[CATransaction commit];
JWWalker
+1  A: 

There is a user default for the animation speed of sheets. Look it up and see what happens if you try to set it to 0.

Mike Abdullah
To save others the trouble of looking it up, it's `NSWindowResizeTime`, and here's a discussion: http://www.macosxhints.com/article.php?story=2004051208143172
JWWalker
Thanks. I've made the answer a wiki, so feel free to add any info to it.
Mike Abdullah