[futurebasic] DockTile badge

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

From: Bernie <fblist.bw@...>
Date: Fri, 15 Jan 2010 20:25:20 +0000
In Carbon, to add a badge to an application's Dock icon, we would normally have to create a CGImageRef of the badge then call OverlayApplicationDockTileImage. However, if all we want to do is add some text to a little red labelly thing (similar to Mail.app's unread message count), then Cocoa has a method for it:
'---------------
// set 'Compile as Objective-C' in FBtoC prefs
BeginCFunction
void DockTileSetBadgeLabel( CFStringRef string )
{
 NSApplicationLoad();
 NSDockTile *dockTile = [NSApp dockTile];
 [dockTile setBadgeLabel:(NSString *)string];
 [dockTile display]; 
}
EndC
toolbox DockTileSetBadgeLabel( CFStringRef string )

DockTileSetBadgeLabel( @"10" )// send a null string to remove badge

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


Bernie




Attachments: