I can set background color for NSTextView, also insertion color, but when I try to change text color it just doesn't work.
I can set the color programmatically before each insert of text, but I'm probably doing something wrong, since Interface Builder offers this options.
Here's what my inspector looks like:
Here is what I have tried below and the results I've found which led me to my conclusion.
(a)Add NSTextView (b)change color. Result: Does not work
(a)Add NSTextView (b)then change the text (c) press enter because it failed when i didnt press enter (d) then change the color. Result: Works
If the text
property of the NSTextView is not set in Interface-Builder, it does not seem to save the text color property. Thus causing the app to select the default color upon launch. The other properties such as Background-Color and Insertion color however, are saved. This leads me to think this is a bug in interface builder.
As a workaround, you can leave single blank space in the text box and the set your color in interface builder, but this might not be favorable for you depending on what you wish to do with the NSTextView
As far as I can see - there's a bug in appkit as of (10.10) when the text is not initialized. This hack got me out of trouble.
NSTextView *tf =
tf.delegate = self;
- (void)textDidChange:(NSNotification *)aNotification {
NSLog(@"notificaiton:%@",aNotification);
NSMTextView *tv = (NSMTextView *)[aNotification object];
[tv setTextColor:[NSColor whiteColor]];
[[tv textStorage] setFont:[NSFont systemFontOfSize:30]];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With