Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display image in a cocoa status app

Hi I developed a cocoa status app. when I put a long title for example , it can't be shown and if i put an image as icon too it can't be shown , but if i put a small title it works correctly. How can I fix this problem and make the image shown?

statusItem = [[[NSStatusBar systemStatusBar] 
    statusItemWithLength:NSSquareStatusItemLength] retain];    

[statusItem setMenu:menu]; 
//[statusItem setTitle:@"Notif "]; 
[statusItem setImage:[NSImage imageNamed:@"image"]]; 
[statusItem setHighlightMode:YES];
like image 801
user1503496 Avatar asked Jul 10 '12 10:07

user1503496


1 Answers

Basically

NSStatusItem *statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
NSImage* icon = [NSImage alloc] initWith ...]
[statusItem setImage:icon];

But your image has to be at a correct size (less than 20*20)

like image 109
Matthieu Riegler Avatar answered Oct 15 '22 00:10

Matthieu Riegler