mardi 16 octobre 2018

NSButton attributedTitle changes color on button down

I created a Cocoa app with a button on it, having the "Check" style and "Switch" type. It is set to a custom class MyButton:

@interface MyButton : NSButton
- (void)awakeFromNib;
@end

This custom class sets attributedTitle:

@implementation MyButton
- (void)awakeFromNib {
    [super awakeFromNib];       
    [self setAttributedTitle:[[NSAttributedString alloc] initWithString:@"Hallo" attributes:@{
    }]];
}
@end

When the button is checked, the font color changes on mouse-down.

I read that NSAttributedString's default color is black, but when I set it explicitly, it stays black on mouse-down. If I explicitly ask for [NSColor controlTextColor], the color switches on mouse-down. Is this behaviour documented somewhere? Is it intended or a bug?




Aucun commentaire:

Enregistrer un commentaire