PDA

View Full Version : NSStatusItem?




semaja2
Feb 1, 2007, 08:54 AM
Hey, it seems the only guide that worked and everyone liked is giving me a 404, so does anyone know of some good guides or examples that are very easy to understand?

Im at the moment trying to read the growl source code but im lost in the code



whooleytoo
Feb 1, 2007, 01:54 PM
Hey, it seems the only guide that worked and everyone liked is giving me a 404, so does anyone know of some good guides or examples that are very easy to understand?

Im at the moment trying to read the growl source code but im lost in the code

I've the source code of mine at home, I can post it tomorrow, if no one else has answered by then.

whooleytoo
Feb 2, 2007, 05:46 AM
You could use the following. _systemMenu is an instance NSStatusItem* variable, and _menu is an IBOutlet pointing to a menu in the app's nib file.


- (void) showMenubarIcon
{
NSImage* icon = [NSImage imageNamed:@"MenuIcon"] ;

NSStatusBar* bar = [NSStatusBar systemStatusBar] ;
_systemMenu = [bar statusItemWithLength:NSSquareStatusItemLength] ;
[_systemMenu retain] ;

[_systemMenu setTitle: nil] ;
[_systemMenu setImage:icon] ;
[_systemMenu setHighlightMode:YES] ;
[_systemMenu setMenu:_menu] ;
}

- (void) hideMenubarIcon
{
[_systemMenu release] ;
_systemMenu = nil ;
}

semaja2
Feb 2, 2007, 09:07 AM
Thanks Whooelytoo, greatly appreciated. I used your code and some other examples to finally come up with my solution but i thought i should write a guide up for anyone else that might want to do this and is also a extreme n00b at ObjC :P

So if anyone wants to check out my first guide ive ever written : http://files.semaja2.net/NSStatusItem%20-%20ObjC.html

Comments appreciated and so is constructive criticism (I know about the missing bits in the @interface i will fix these up when i learn about them :P )

CaptainZap
Feb 2, 2007, 05:00 PM
Hey great guide Semaja, I'm sure once I learn more about Obj-C and Cocoa I'll be using it =].

semaja2
Feb 2, 2007, 06:00 PM
Hey great guide Semaja, I'm sure once I learn more about Obj-C and Cocoa I'll be using it =].

Thanks ill be making it into a proper HTML page and stuff later on, the one in that link is just a export from pages so its kinda bloaty ;)

janey
Feb 3, 2007, 03:55 AM
thanks whooleytoo and semaja2 :D
i've been looking around for guides and sample code, not much luck. great timing, as i was about to give up too :p

One thing though, the screenshots on the guide are really blurry - I know what you're doing and i get the point from the shots, but it's still blurry :(

on second thought, i just looked at an image and it's only blurry because it's enlarged in the guide..nevermind :D :o

kainjow
Feb 3, 2007, 03:52 PM
I would suggest posting your guide at cocoadev.com also, so that others can find it easily, and if your site goes down or something, it'll always be accessible on cocoadev.com :)

semaja2
Feb 3, 2007, 04:35 PM
kainjow: thanks for the suggestion, once i finish the guide (few little bits needed cleaning) ill either post the link or have them host it

janey: i have a upcoming guide that explains how to interface with the Apple Remote, but im might increase the required base knowledge so that i can cut down on the confusion caused by the many screenshots i know have in the new guide :P

as for the screenshots, they were only added for a quick reference not to actually be read but your not the only one bringing up the point on bad quality