NSStatusItem全屏问题 [英] NSStatusItem fullscreen issues

查看:183
本文介绍了NSStatusItem全屏问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个状态栏应用程序,当NSStatusItem点击时显示NSPopover,如下所示:

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

我已经添加了通过拖动边缘, popover的视图如下:

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.

看起来popover不是重绘时调用全屏环境。有没有办法解决这个问题?

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

推荐答案

这里在WWDC。提出同样的问题。您必须拥有一个应用程序,它是一个UIElement应用程序 - 意味着没有停靠图标,没有主菜单。

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.

这篇关于NSStatusItem全屏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆