title: Mac OSX NSStatusItem with Custom NSMenu/MenuItems AND Drag And Drop functionality
body: <p>I am trying to create a Mac Application that has an NSStatusItem icon in the Status Bar. The status bar icon should support file drag and drop and must also show a menu when clicked.</p>
  <p>The problem is that I have managed to achieve both functionalities separately and am having a hard time merging them together.</p>
  <p>I was able to create a Status Bar Application using this link :</p>
  <p><a href="http://cocoatutorial.grapewave.com/2010/01/creating-a-status-bar-application/" rel="nofollow noreferrer">http://cocoatutorial.grapewave.com/2010/01/creating-a-status-bar-application/</a></p>
  <p>And then I was able to achieve drag and drop functionality on the status bar icon using the following link</p>
  <p><a href="https://stackoverflow.com/questions/5663887/drag-and-drop-with-nsstatusitem/6493240#6493240">Drag and Drop with NSStatusItem</a></p>
  <p>The problem that I am facing is as follows, in order to get drag and drop, I have to create another view and then assign that view to the NSStatusItem as shown below :</p>
  <pre><code>NSStatusItem *statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
  
  ViewWithDragFunctionality* viewWithDrag = [[ViewWithDragFunctionality alloc] initWithFrame:NSMakeRect(0, 0, 24, 24)];
  [statusItem.view addSubview:viewWithDrag];
  </code></pre>
  <p>Since this is just a view, it does not, obviously, behave as the NSStatusItem's default view and does not support mouse interactions or anything else.
  I managed to find a way around that by adding the following function to ViewWithDragFunctionality.m</p>
  <pre><code>- (void)mouseDown:(NSEvent *)theEvent {
      NSLog(@&quot;Status Bar Icon Clicked&quot;);
  }
  </code></pre>
  <p>The function is called whenever the status bar icon is clicked and file drag and drop is also being detected.</p>
  <p><strong>But</strong> now I am stuck with figuring out how to get the menu to display when clicking the status bar icon.</p>
  <p>Any help will be much appreciated. I am working on a solution for this and will post it here if I find something first :)</p>
  <p>Regards</p>
  <p>Shumais</p>