Re: Displaying an alert box
Re: Displaying an alert box
- Subject: Re: Displaying an alert box
- From: Douglas Davidson <email@hidden>
- Date: Mon, 15 Oct 2001 09:48:33 -0700
Let me expand a little on the distinction between NSAlert and
CFUserNotification.
NSAlert is the standard means for a Cocoa application to put up an alert
dialogue. It is the appropriate way for an application to alert the
user about goings on in that application ("This document is 500 pages
long. Are you sure you wish to discard it?"). When an application
other than the currently active one puts up an NSAlert, Cocoa generally
makes efforts to notify the user by some means that the application
needs attention, though the actual means used may potentially depend on
the OS version or on user preferences (for example, once we have
holographic displays, the application's icon might jump out of the
screen and do a backflip). You should be able to find information on
NSAlert among the Cocoa reference documentation.
The primary design purpose of the User Notification Center, AKA
CFUserNotification, is to provide means for background processes, system
daemons, the kernel, and other tasks that otherwise do not have a GUI
interface, to have some limited form of interaction with the user--for
example, to request a necessary password, or to notify the user of some
significant happening ("Your computer has caught on fire. Please
extinguish it."). It has low-level interfaces (CFUserNotification is
the CF-level one) so that it can be used almost anywhere in the system.
The promise it makes is that it will attempt to present the notification
requested to a user at the console in some form, if possible, but it
does not guarantee what form this will take. It can also be used by
applications that have GUI interfaces of their own, but this should be
done sparingly, because the form it takes is often quite intrusive
(currently it will usually put up dialogues that float above almost
everything else, although they are non-modal and can be moved out of the
way). The only documentation I know of at the moment for
CFUserNotification is in the header file, but I can provide some sample
code for those who need help.
Douglas Davidson
On Monday, October 15, 2001, at 03:17 AM, Stiphane Sudre wrote:
On dimanche, octobre 14, 2001, at 05:02 , David McCabe wrote:
How about in Objective-C?
On Saturday, October 13, 2001, at 06:32 PM, Simon Wright wrote:
On Saturday, October 13, 2001, at 08:30 PM, David McCabe wrote:
Greetings,
I would like to have my application display an alert panel which
comes to the foreground above all other applications. Despite the
simplicity of this task, I have found nothing in the documentation
about displaying alerts of any kind, except a small bit on sheets.
Can any of you help?
Thanks!
How about CFUserNotification ?
SInt32 CFUserNotificationDisplayAlert(CFTimeInterval timeout,
CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef
localizationURL, CFStringRef alertHeader, CFStringRef alertMessage,
CFStringRef defaultButtonTitle, CFStringRef alternateButtonTitle,
CFStringRef otherButtonTitle, CFOptionFlags *responseFlags);