简体   繁体   中英

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. 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. The view has set clear color for the background color on its 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.

A fake window seems like a rather weird approach to this. Why not just pop up a regular window? I suggest MAAttachedWindow: http://mattgemmell.com/2007/10/03/maattachedwindow-nswindow-subclass

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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