如何拖动 NSStatusItems [英] How to drag NSStatusItems

查看:19
本文介绍了如何拖动 NSStatusItems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你们都知道 Mac OS X 中的菜单栏(或者更好的说法是 NSStatusBar).
有些物品我可以移动,有些则不能.

You all know the menu bar (or better said NSStatusBar) in Mac OS X.
There are some items which I can move and other which not.

我希望能够拖动我的应用的 NSStatusItem.

I would like to be able to drag the NSStatusItem of my app.

知道如何实现吗?

推荐答案

虽然 NSStatusItems 出现在 Apple 内部的菜单附加项"附近,但它们是截然不同的并且表现不同.如果 Apple 统一了可以出现在菜单栏右侧区域的项目,那就太好了,但现在该部分分为不同的苹果内部"(右侧)和应用程序提供的(NSStatusItem)"在左边.

Although NSStatusItems appear near Apple's internal "menu extras", they are distinct and behave differently. It would be nice if Apple unified the items that can appear in the right-hand area of the menu bar, but for now the section is split into distinct "apple internal" (on the right), and "app-provided (NSStatusItem)" on the left.

您可以通过将计算机置于屏幕捕获模式 (cmd-shift-4) 并按空格键切换到捕获整个窗口"来查看区别.当您将鼠标悬停在 Apple 的菜单图标上时,您会看到它们都位于一个窗口中.这解释了它们易于管理和拖拉的能力.将鼠标悬停在其他项目上表明每个 NSStatusItem 实际上都存在于它自己的单个窗口中(恰好由安装它的应用程序拥有).

You can visualize the distinction by putting your computer into screen capture mode (cmd-shift-4), and pressing the space bar to switch to "capture whole window". When you hover over Apple's menu icons, you'll see that they all live in a single window. This explains their ability to be easily managed and dragged about. Hovering over the other items reveals that each NSStatusItem is in fact living in a single window of its own (which happens to be owned by the application that installed it).

最好坚持使用 NSStatusItem,即使你不能拖动它们.这是 Apple 的一个缺点,大多数用户都会理解,即使它很烦人.强调长期提供更稳定的应用程序的积极权衡通常会软化推动可拖动性的客户(或经理?)的意见.

It's best to stick with NSStatusItem even though you can't drag them. It's a shortcoming from Apple which most users will understand, even if it's annoying. Emphasizing the positive tradeoffs of offering a more stable application for the long term will usually soften the opinions of your customers (or managers?) who are pushing for the draggability.

这篇关于如何拖动 NSStatusItems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆