简体   繁体   English

在 NSMenuItem 内带有 NSView 的假 NSWindow

[英]Fake NSWindow with a NSView inside a NSMenuItem

Before I start I should say I know this seems like a long shot, however I figured it was worth a try.在开始之前,我应该说我知道这似乎是一个很长的尝试,但我认为值得一试。

One app I am working on right now is a Mac Statusbar App.我现在正在开发的一个应用程序是 Mac 状态栏应用程序。 It has a NSStatusItem in the menubar and when clicked it will display a custom window with a popover appearance (like on iPad or like Fantastical has on the mac.) Anyway I started testing this by inserting a single nsmenu item in the status items menu.它在菜单栏中有一个 NSStatusItem ,当单击它时,它将显示一个自定义 window 并带有弹出窗口外观(如 iPad 或 Mac 上的 Fantastical 一样。)无论如何,我通过在状态项目菜单中插入一个 nsmenu 项目开始测试它。 The view has set clear color for the background color on its window.该视图已为其 window 上的背景颜色设置了清晰的颜色。 However this still doesn't quite work as you can see in the pic below但是,这仍然不太有效,如下图所示

在此处输入图像描述

  1. There is still a small white thin line above and below the item物品上方和下方仍有一条小的白色细线
  2. The clear area isn't clear, its like it has a blur filter on it清晰区域不清晰,就像上面有模糊滤镜一样

Other than that, it works fantastically great.除此之外,它的效果非常好。 I just didn't know if anybody else has ever attempted anything like this before and figured out how to overcome these 2 issues which seem to be the only thing preventing this from working.我只是不知道其他人是否曾经尝试过这样的事情,并想出如何克服这两个问题,这似乎是唯一阻止它工作的事情。

If there is no way to do this I may have to resort to using a custom view for the NSStatusItem so I can get the coordinates on screen to position my own window below the NSStatusItem.如果没有办法做到这一点,我可能不得不求助于对 NSStatusItem 使用自定义视图,这样我就可以在屏幕上的坐标到 position 我自己的 window 下面的 NSStatusItem。

A fake window seems like a rather weird approach to this.一个假的 window 似乎是一种相当奇怪的方法。 Why not just pop up a regular window?为什么不直接弹出一个常规的 window? I suggest MAAttachedWindow: http://mattgemmell.com/2007/10/03/maattachedwindow-nswindow-subclass我建议 MAAttachedWindow: http://mattgemmell.com/2007/10/03/maattachedwindow-nswindow-subclass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM