Posted By

iHaz3-Dev on 06/13/13


Tagged

- -Menu -NSObject -Statusbar -SystemStatusBar trayItem


Versions (?)

Adding to OS X Status Tray


 / Published in: Objective C
 

  1. //
  2. // Document.m
  3. //
  4. // Created by Cubi-Development 26/5/2013.
  5. // Copyright (c) 2013 Cubi-Development Inc. All rights reserved.
  6. //
  7. //
  8. // ^^^___^^^^^^_^^^^^_^^^^^^^^^___^^^^^^^^^^^^^^^_^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^_^^^
  9. // ^^/^__\^^^_|^|__^(_)^^^^^^^/^^^\_____^^^_____|^|^___^^_^__^^_^__^___^^^___^_^__^|^|_^
  10. // ^/^/^|^|^|^|^'_^\|^|_____^/^/\^/^_^\^\^/^/^_^\^|/^_^\|^'_^\|^'_^`^_^\^/^_^\^'_^\|^__|
  11. // /^/__|^|_|^|^|_)^|^|_____/^/_//^^__/\^V^/^^__/^|^(_)^|^|_)^|^|^|^|^|^|^^__/^|^|^|^|_^
  12. // \____/\__,_|_.__/|_|^^^^/___,'^\___|^\_/^\___|_|\___/|^.__/|_|^|_|^|_|\___|_|^|_|\__|
  13. // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  14. //
  15.  
  16.  
  17. @interface Tray : NSObject <NSApplicationDelegate> {
  18. NSStatusItem *trayItem;
  19. }
  20. @end
  21.  
  22. @implementation Tray
  23.  
  24. - (IBAction)testAction:(id)sender;
  25. {
  26. NSLog(@"Hello Babe");
  27. }
  28.  
  29. - (IBAction)quitAction:(id)sender;
  30. {
  31. [NSApp terminate:sender];
  32. }
  33.  
  34. - (void)applicationDidFinishLaunching:(NSNotification *)note;
  35. {
  36. NSZone *zone = [NSMenu menuZone];
  37. NSMenu *menu = [[[NSMenu allocWithZone:zone] init] autorelease];
  38. NSMenuItem *item;
  39.  
  40. item = [menu addItemWithTitle:@"Testing" action:@selector(testAction:) keyEquivalent:@""];
  41. [item setTarget:self];
  42.  
  43. item = [menu addItemWithTitle:@"Quit" action:@selector(quitAction:) keyEquivalent:@""];
  44. [item setTarget:self];
  45.  
  46. trayItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
  47. [trayItem setMenu:menu];
  48. [trayItem setHighlightMode:YES];
  49. [trayItem setTitle:@"HERE"];
  50. }
  51.  
  52. - (void)dealloc;
  53. {
  54. [trayItem release];
  55. [super dealloc];
  56. }
  57.  
  58. @end
  59.  
  60.  
  61. // Copyright (c) 2013 Cubi-Development Inc. All rights reserved.

Report this snippet  

You need to login to post a comment.