Opaque text in NSTextField


Gerriet M. Denkmann
 

I have an NSTextField (macOS 13.4, Xcode Version 9.3 (9E145)) which says:

textColour Generic Gray colorspace 1 1
backGroundColour NSCalibratedWhiteColorSpace 0 0.4

This, I guess, means all white and all opaque text.
And partly translucent black background.

The background is partly translucent as expected.
But the text comes out as semi-translucent grey.

How can I get really white opaque text?

Gerriet.


Gerriet M. Denkmann
 

To answer my own question:

On 11 May 2018, at 11:44, Gerriet M. Denkmann <g@...> wrote:

I have an NSTextField (macOS 13.4, Xcode Version 9.3 (9E145)) which says:

textColour Generic Gray colorspace 1 1
backGroundColour NSCalibratedWhiteColorSpace 0 0.4

This, I guess, means all white and all opaque text.
And partly translucent black background.

The background is partly translucent as expected.
But the text comes out as semi-translucent grey.

How can I get really white opaque text?
textField.stringValue = someString;

When I look at the attributedStringValue I see Generic Gray colorspace 1 0.5

So I do:
NSMutableAttributedString *mus = [ textField.attributedStringValue mutableCopy ];
[ mus addAttribute: NSForegroundColorAttributeName value: textField.textColor range: NSMakeRange(0, someString.length) ];
textField.attributedStringValue = mus;

I have no idea who changes the alpha of textColor from 1 to 0.5 and why.

Gerriet.