Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MrFusion

macrumors 6502a
Original poster
Jun 8, 2005
613
0
West-Europe
I found out how to add and remove a badge to the dockicon (like the number of unread mails in the dockicon of Mail). I also know how to bounce the dockicon. The bouncing stops either after 1 second of when the user activates the program. In addition, I want to remove the badge from the dockicon when the app becomes active. The NSWorkspaceDidActivateApplicationNotification is received for every app. How do I find out if its is my app for the current user?
Both if conditionals in the becameActive: method don't work. Any idea how to correct this? Thanks!

Code:
- (id)init 
{
    self = [super init];
    if (self != nil) {
		[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
												 selector:@selector(becameActive:)
													 name:NSWorkspaceDidActivateApplicationNotification
												   object:nil];
    }
    return self;
}
-(void) becameActive:(NSNotification *)notification {
	if ([notification object] == NSApp)
		[[NSApp dockTile] setBadgeLabel:nil];

	NSRunningApplication *runApp = [[notification userInfo] valueForKey:@"NSWorkspaceApplicationKey"];
	if (runApp == [NSRunningApplication currentApplication])
		[[NSApp dockTile] setBadgeLabel:nil];

}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.