[fbcocoa] Re: [fbcocoa] Notification Manager ( old ) replacement

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2010 : Group Archive : Group : All Groups

From: Brian S <fblistserve@...>
Date: Thu, 1 Jul 2010 09:14:29 -0700
On Jul 1, 2010, at 4:02 AM, Bernie wrote:

> 
> This version combines dock bounce and alert in one call. It also eliminates multiple alerts.

Thanks Bernie. I will review it later today.

> 
>  [[NSApplication sharedApplication] requestUserAttention:NSCriticalRequest];

My own attempt failed with a “kCGErrorInvalidConnection” runtime error ( i.e. it compiled and linked fine ) which says the connection to the window server failed.

The above call to sharedApplication is apparently the key and its description sounds like it would solve my issue. Your prior example clearly uses the call but I overlooked its importance.

Question: how did you discover the NSApplication sharedApplication call was required? When I was coding my own example yesterday ( see my Q&D attempt below just for grins ) it was clear something was missing but I didn’t find a simple solution.

Thanks again,

Brian S




'--------------
BeginCFunction
#import <Cocoa/Cocoa.h>

UInt32 MyShowAlert( CFStringRef okBtn, CFStringRef canBtn, CFStringRef msg1, CFStringRef msg2, NSAlertStyle warningStyle )
{
 NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
 NSAlert *alert = [[NSAlert alloc] init];

 [alert addButtonWithTitle:(NSString *)okBtn];

 [alert addButtonWithTitle:(NSString *)canBtn];

 [alert setMessageText:(NSString *)msg1];

 [alert setInformativeText:(NSString *)msg2];

 [alert setAlertStyle:(NSAlertStyle)warningStyle];
 NSInteger whichBtn = [alert runModal];
 [alert release];
 [localPool release];
 return whichBtn;
}

EndC
toolbox fn MyShowAlert( CFStringRef okBtn, CFStringRef canBtn, CFStringRef msg1, CFStringRef msg2, UInt32 warningStyle ) = UInt32

fn MyShowAlert( @"OK", @"Cancel", @"Delete Contents of Disk?", @"Warning: Could be fatal!", 1 )

RunApplicationEventLoop()
'--------------