举个好例子,只需在使用多个显示器时点击DropBox状态图标即可.你会注意到在另一个屏幕上选择了图标.
解决方法 来自JlinX Apple Dev Forums提到的Apple的回应:总结Status Items with multiple menu bars
10.9 introduces multiple menu bars,each of which draws the status items. If your status item has a custom vIEw,this vIEw is positioned in one menu bar,and other menu bars get a “clone”,which looks IDentical. The clones are not exposed in the API. The clones are drawn by redirecting your custom vIEw’s drawing into another window. This means that your status item should not make assumptions about the drawing destination. For example,it should not assume that a call to drawRect: is destined for the vIEw’s window,or that the resolution of the drawing destination matches the resolution of the status item’s screen. You must also not assume that the status item is on any particular display,except as described below. The clones are only redrawn in NSDefaultRunLoopMode. This allows the status item to limit highlighting to one display,by driving the run loop in another mode,such as NSEventTrackingRunLoopMode. For example,if you wish to simulate a menu,you would implement mouseDown: to show your window,and run the run loop in NSEventTrackingRunLoopMode until you determine that the window should be dismissed. While the run loop is in this mode,only the true status item will redraw. Clone status items will not redraw,and therefore they will not show any highlight applIEd to the true status item. When a clone status item is clicked,the clone exchanges locations with the true status item. This means that the location and screen of the status item window is reliable from within mouseDown:. You can access this information from your custom vIEw,for example,using [[vIEw window] screen] to position a window on the same screen as the status item.
以上是内存溢出为你收集整理的macos – Mavericks和NSStatusItem的多个监视器的自定义视图全部内容,希望文章能够帮你解决macos – Mavericks和NSStatusItem的多个监视器的自定义视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)