NSStatusItem fullscreen issues

自闭症网瘾萝莉.ら 提交于 2020-01-01 12:00:06

问题


I'm making a statusbar app that displays an NSPopover when the NSStatusItem is clicked, like this:

I have added the ability to resize the popover by dragging on the edges, by subclassing the popover's view like this:

class CMView: NSView {
    let tolerance : CGFloat = 10
    var state = false

    override func mouseDown(theEvent: NSEvent) {
        let point = self.convertPoint(theEvent.locationInWindow, fromView: nil)
        if (point.y <= tolerance) {
            state = true
        }
    }
    override func mouseDragged(theEvent: NSEvent) {
        if (state) {
            let point = self.convertPoint(theEvent.locationInWindow, fromView: nil)
            self.frame = NSRect(
                x: self.frame.origin.x,
                y: self.frame.origin.y,
                width: self.frame.size.width,
                height: self.frame.size.height-point.y)
            popover.contentSize = self.frame.size
        }
    }
    override func mouseUp(theEvent: NSEvent) {
        state = false
    }
}

This only works if the desktop isn't in full screen. If I try to resize it in fullscreen, it simply doesn't work, and the popover arrow disappears mysteriously.

It seems like the popover isn't redrawing when invoked in a fullscreen environment. Is there any way around this problem?


回答1:


Here at WWDC. Asking the same question. You have to have an app that's an UIElement app - meaning no dock icon, no main menu.



来源:https://stackoverflow.com/questions/29153729/nsstatusitem-fullscreen-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!