Among write off the grid input method the Mac version of the process，I encountered such a problem，Article candidate system API disrepair，Many API functions exists but is essentially useless，such as：
@abstract Sets the "style" attributes for the candidates window. The keys for the attributes dictionary and the values are:
NSFontAttributeName (value = NSFont) Setting the font attribute sets the font that is used to draw Candidates. It does not effect the selection keys which are always drawn in the same font. Note that to set the font size you should use this key/value pair.
IMKCandidatesOpacityAttributeName (value = NSNumber with a float value between 0 and 1). Sets the opacity level to transparent (0.0) to completely opaque (1.0). The default opacity is 1.0. This constant is declared above.
NSForegroundColorAttributeName (value = NSColor) Sets the text color used for the candidate text. By default it is black.
NSBackgroundColorDocumentAttribute (value = NSColor). Set the background color that is drawn behind the candidate text.
IMKCandidatesSendServerKeyEventFirst (value = NSNumber). NO (default) gives the candidate window first chance at key events. YES causes events to first be routed to the current IMKInputController. In that case, if the event is not handled, it will then be sent to the candidate window.
open func setAttributes(_ attributes: [AnyHashable : Any]!)
This method is used to set the style of a candidate bar，In addition to the default inside IMKCandidatesSendServerKeyEventFirst This can take effect outside，The other not ignore。
This awkward，Now pingming frequently high 4k to retina or，The default number of 16 candidates font looks also not blind the eyes。
So，Finally, I still have to achieve their own candidate for this article，How to say after layout，But here there is a very interesting point can talk about，That is how to make this NSWindow The user can input points to go along with，Instead of being "trapped" in the first screen。
First of all，I like this design
With a NSWindow Add to renovate，Then as a candidate bar，Call it makeKeyAndOrderFront To show，Then close To close，Then I encountered the first problem：transfer close Rear，This window has been released! Cause program execution to force the null pointer，Although Swift I like this statement where candidatesWindow:CandidateController 。
So，I began to think of the older generation learned valuable lessons in the OC，use self.ALPHAVALUE To get this thing。
after all，Transparent is equivalent to a hidden，Can not interact，After I rewrote a series of methods，It looks good job。but，Users will soon have reported problems，He said candidate bar sometimes missing，That can type but no candidate bar ...... I thought it was inserted into the coordinates of the cursor to get the error ...... eventually, after I accidentally switched Space to reproduce the problem，The original candidate bar and no deviation，Except that it is displayed in another screen space。
So I started looking for how to NSWindow Move to approach the target screen - in fact, after a lot of，Unfortunately really is not moving NSWindow Space the way to the target - which embarrassed。
Then after 3 hours，I gave up this road，Back to square one。
Now back to square one，So I started the design concept is actually quite correct，So contradiction is how to let this window is not automatically released。Unfortunately, the Internet to find a circle，We are actually asking how to make the right release window - Well，I think it's very own release positive ........................
In short，This time I thought of this Controller，After all, it does not own their own to release - so the question is，If I close The NSWindowController ，It will be released it?
--fortunately，It should be clear that，will not。So，I changed to use NSWindowController ，Then during initialization to initialize the window。So when I need to show the candidate field，I can do it：
When I need to close when，To do so：
Such，On the whole window manager NSWindowController Automatic arrangements，Then the focus here：
Because each window is no longer simply moving position and modify the transparency，Window appears and disappears is a real addition and removal，This naturally support the display screen in any position，This time，Candidate bar can support multi-screen、A multi-Space。
Original article written by Gerber drop-off：R0uter's Blog » How to make NSWindow displayed in a different Space or the Screen
Reproduced Please keep the source and description link：https://www.logcg.com/archives/2769.html