如何从代码中关闭 OSX 字符选择器调色板

Gar*_*son 5 macos nswindow swift

我可以通过以下方式呈现字符选择器调色板(表情符号):

NSApplication.shared.orderFrontCharacterPalette(self)
Run Code Online (Sandbox Code Playgroud)

但当我愿意时,我找不到任何方法从代码中关闭字符选择器调色板。

我尝试迭代所有打开的窗口,并像这样关闭除主窗口之外的所有窗口,但尽管我的 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
        }
    }
Run Code Online (Sandbox Code Playgroud)