I'm trying to write an application that allows the user to drag files from the Finder and drop them onto an NSStatusItem
. So far, I've created a custom view that implements the drag and drop interface. When I add this view as a subview of an NSWindow
it all works correctly -- the mouse cursor gives appropriate feedback, and when dropped my code gets executed.
However, when I use the same view as an NSStatusItem's
view it doesn't behave correctly. The mouse cursor gives appropriate feedback indicating that the file can be dropped, but when I drop the file my drop code never gets executed.
Is there something special I need to do to enable drag and drop with an NSStatusItem
?
Since Yosemite, the method for setting a view on
NSStatusItem
is deprecated but fortunately there is a much nicer way using the newNSStatusItemButton
property onNSStatusItem
:}
Please be aware that the
button
property is only available starting in 10.10 and you might have to keep your old solution if you support 10.9 Mavericks or below.I finally got around to testing this and it works perfectly, so there's definitely something wrong with your code.
Here's a custom view that allows dragging:
Here's how you'd create the status item: