I'd like to enable the user to change the font of an view-based NSTableView
. I'm using Cocoa bindings and Core Data. In my test code, I do have a changeFont:
method that does get called as soon as I press a font-related key combination, like cmd-I
or cmd-B
, but I've had no luck so far in changing the actual font of the table view:
- (void)changeFont:(id)sender
{
NSFont *oldFont = [self.airportTableView font];
NSFont *newFont = [sender convertFont:oldFont];
NSLog(@"sender: %@ oldfont: %@, newFont: %@ fontmanager selected: %@, font panel selected: %@",
sender, oldFont, newFont, [sender selectedFont], [sender convertFont:[sender selectedFont]]);
[self.airportTableView setFont:newFont];
}
produces the following output:
sender: <NSFontManager: 0x6080000b4580> oldfont: (null), newFont: (null) fontmanager selected: (null), font panel selected: (null)
Even this trivial code:
font = [NSFont boldSystemFontOfSize:12];
[self.airportTableView setFont:font];
NSFont *oldFont = [self.airportTableView font];
NSLog(@"oldfont: %@",oldFont);
only results in:
oldfont: (null)
Can any kind soul provide some code that allows the user to change the font of an NSTableView?