如何从代码中解除OSX字符选择器调色板

时间:2018-01-07 21:29:26

标签: swift macos nswindow

我可以使用:

呈现字符选择器调色板(表情符号)
NSApplication.shared.orderFrontCharacterPalette(self)

但是当我想要的时候,我无法从代码中找到任何解除字符选择器调色板的方法。

我已经尝试遍历所有打开的窗口,并关闭除了主窗口之外的所有窗口,但是虽然我的print语句报告了其他2个窗口,但它并没有关闭字符选择器调色板:

    let openwindows = NSApplication.shared.windows
    for win in openwindows {
        if win == self.view.window {
            print("Found and ruled out the main window") // successfull
        }else{
            print(win.className)
            // finds two other windows and prints
            // _NSCandidateBarCorrectionPanel
            // NSCorrectionSubPanel
            //
            win.close() // Has no effect
            // win.orderOut(self) // Has no effect
            // win.performClose(nil) // sounds system beep
        }
    }

0 个答案:

没有答案