Improving growlNotificationWasClicked

0 views
Skip to first unread message

nskboy

unread,
May 6, 2008, 7:56:09 AM5/6/08
to Growl Discuss
In Cocoa there is setRepresentedObject/representedObject methods of
NSMenuItem object which allow programmer to do some extra job when
NSMenuItem is clicked for example. Is there similar functionality in
Growl? For example, I'd like to set a NSURL object for notification
and when notification is clicked application should open this URL in
browser. Is this possible?

Peter Hosey

unread,
May 6, 2008, 8:16:10 AM5/6/08
to growld...@googlegroups.com
On May 06, 2008, at 04:56:09, nskboy wrote:
> For example, I'd like to set a NSURL object for notification and
> when notification is clicked application should open this URL in
> browser. Is this possible?

Yes. As part of the notification, you pass a click context object.
This object can be any property-list object (dictionary, array,
string, data, number, or date). Remember that the container types can
only contain other property-lists: an array of NSImages is not a
valid property list.

So, the immediate solution is to take the absoluteString of the URL,
and in your delegate's click callback, re-create the NSURL from the
string.

If you have other notifications that you'd like to use strings for,
you can use the more general solution: set a dictionary as the click
context, and put the URL absoluteString into it. You can use any key
you want.

nskboy

unread,
May 6, 2008, 9:26:37 AM5/6/08
to Growl Discuss
Thank you for detailed response! Your help is appreciated.
Reply all
Reply to author
Forward
0 new messages