Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSAlert without bouncing dock icon

Tags:

macos

cocoa

If you put up an NSAlert while your app is in the background your dock icon starts bouncing and keeps on bouncing until you switch back.

I find this annoying.

Does anyone know how disable that for a single app?

like image 521
Rhythmic Fistman Avatar asked Nov 17 '08 11:11

Rhythmic Fistman


1 Answers

Create your own subclass of NSApplication, and implement something like this:

- (int)requestUserAttention:(NSRequestUserAttentionType)requestType
    {
        if (dontDoThatBouncyThing) {
            return 0;
        }
        return [super requestUserAttention:requestType];
    }

Don't forget to change "NSPrincipalClass" in your Info.plist from NSApplication to your own NSApplication subclass.

like image 63
Dirk Stoop Avatar answered Oct 20 '22 11:10

Dirk Stoop