1

I'm developing a Cocoa based application for Mac in Swift. I'm looking for how to have the file path of a file I drag and drop to the status bar icon of the app.

I created my status bar icon in AppDelegate with

func applicationDidFinishLaunching(aNotification: NSNotification) {
    let icon = NSImage(named: "statusIcon")
    icon?.setTemplate(true)
    statusItem.image = icon
    statusItem.menu = statusMenu
    ...
}
Tupac
  • 73
  • 1
  • 6
  • The code snippet you put in your question simply adds the status item to the system menu bar, but have you written any of the code for your status item to actually receive the dragged file? – Michael Dautermann Jun 01 '15 at 18:40
  • I didn't write anything for the status item but I did it for a window with a class for a NSImageView, including NSDraggingDestination. I'd like to implement this to status item. – Tupac Jun 01 '15 at 18:54
  • Implementing a receive drag is actually a different problem than the question you asked. [You could set a custom view on the status menu item](http://stackoverflow.com/questions/11740702/nsstatusbar-drag-drop-with-menu) & that can receive drags, but [that method](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSStatusItem_Class/index.html#//apple_ref/occ/instm/NSStatusItem/setView:) is deprecated as of MacOS 10.10 (that means it'll still work, but Apple doesn't support it any longer). So maybe you need to find a different dragging solution. – Michael Dautermann Jun 01 '15 at 19:28
  • I'll try this. Do you know a better and more sustainable solution to handle drag and drop? – Tupac Jun 01 '15 at 19:36

0 Answers0