Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个标准的菜单栏应用程序(带有下拉菜单),并希望为我的用户添加将文件拖动到我的菜单栏图标顶部的功能(像这样)。
你知道这是如何实现的吗?
我假设我的菜单栏应用程序必须接受拖放。但真正让我困惑的是弹出视图的动画效果如何。
任何指针将不胜感激!
很简单,您应该制作自己的按钮。您需要一个 nsview 来进行拖放和单击操作以通过委托类打开菜单这里是可以提供帮助的示例,并且此链接用于 nsview 类参考。
现在您应该将此视图设置为状态按钮:
NSStatusItem *_statusItem; _statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; [_statusItem setView:_buttonview];