NSStatusBar drag & drop with menu

不想你离开。 提交于 2019-12-11 11:53:43

问题


I'm familiar with the technique described here: Drag and Drop with NSStatusItem to make an NSStatusBar item that can handle file drag & drop.

What is the proper method for having a status bar item that supports both drag & drop and regular menu interactions, much like the Cloudapp icon does.

I want users to be able to left click the NSStatusItem to see the normal menu listing as well as allow for file drag and drop functionality.

It seems to me like I have to write all my own click handler code if I use a custom view on an NSStatusItem. So I'd have to detect clicks and display my menu items myself manually.

I just want to make sure there is no easier (or better) way before I start implementation.


回答1:


As far as I know you need the custom view on your NSStatusItem to handle the drag and drop. In this case it is easy, though, to add click handling to the view as well. You do not have to draw the menu yourself---if that is what you're asking---it should suffice to call - (void)popUpStatusItemMenu:(NSMenu *)menu on your NSStatusItem.



来源:https://stackoverflow.com/questions/11740702/nsstatusbar-drag-drop-with-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!