How to drag NSStatusItems

后端 未结 3 849
清歌不尽
清歌不尽 2020-12-28 22:49

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.

I would like to be able to drag th

3条回答
  •  不思量自难忘°
    2020-12-28 23:09

    You'll have to use NSMenuExtra, not NSStatusItem, and make the menu item a bundle running inside the SystemUIServer process, not your own app. You'll also need code like that supplied by MenuCracker to get this to work.

    NSMenuExtra is undocumented and unsupported, and therefore considered a "hack".

    My guess for there being two APIs in the first place: a menu extra crashing (or memory leaking) means the entire SystemUIServer process crashing or memory leaking — including other third party modules as well as system-supplied ones. With a status item, on the other hand, such a problem would only affect your own code.

提交回复
热议问题