I just ran into an issue with resetting colours when an NSTextField was selected.
The methods I'm using are
- (void) setBackgroundColor:(NSColor *)aColor
- (void) setTextColor:(NSColor *)aColor
I found that when I clicked in the NSTextField and thereby placed the focus in that text field, then tried to change the colour, the colours were not reset until focus was placed outside of that text field.
The colour change otherwise worked when focus was not on the NSTextField to begin with.
The simple solution I found without having to access the First Responder was to reset the box as editable/not editable after changing the colours.
- (void) setEditable:(BOOL)flag
By setting the value of flag to NO and then YES in 2 subsequent calls (or YES and then NO depending on the usage), this seems to remove the focus from the NSTextField and then place it back, also updating the colours.
Hope this helps.
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