title: How can I set [NSTextView selectedTextAttributes] on a background window?
body: <p>The default value for <code>[NSTextView selectedTextAttributes]</code> is unusable in my app, because i allow the user to select colors (syntax highlighting) that are almost exactly the same as the background color.</p>
  
  <p>I have written some math to determine a suitable color and can use this to set it:</p>
  
  <pre><code>textView.selectedTextAttributes = @{
    NSBackgroundColorAttributeName: [NSColor yellowColor],
    NSForegroundColorAttributeName: [NSColor redColor]
    };
  </code></pre>
  
  <p>But when the window is in the background, it still uses the system default light grey.</p>
  
  <p>I've attached screenshots of the above code with active vs inactive window. — how can I change the selected text background colour of the inactive window?</p>
  
  <p><img src="https://i.stack.imgur.com/LPb3S.png" alt="active">
  <img src="https://i.stack.imgur.com/BXEZW.png" alt="inactive"></p>