Why can't I change the font used by an NSTextField?
Why can't I change the font used by an NSTextField?
- Subject: Why can't I change the font used by an NSTextField?
- From: Matt Mower <email@hidden>
- Date: Tue, 24 Apr 2012 11:17:16 +0100
Hi folks.
I am using a source list view (view based NSOutlineView) and trying to display some items in bold text (using the default system font, not a custom font) and it's not working.
In interface builder I have the default non-group NSTableCellView that was created when I dragged in the source list. I use a subclass to handle the font selection logic but otherwise it's vanilla. My calls to -setStringValue: on the NSTextField work fine.
However calling -setFont: does not change the font that's used to display the item labels in the outline. After calling -setFont: both the NSTextField and it's corresponding cell both respond with the correct font info. But they go ahead and draw in the regular font anyway.
I've tried turning on RichText for the view, no difference.
Finally I tried changing the font directly in InterfaceBuilder. I set it to System font 18pt and in Interface Builder it looks right. But, when I run the app, the outline items are all drawn in the regular font!
At this point the relevant code boils down to:
[[self textField] setFont:[NSFont boldSystemFontOfSize:6.0]];
[[self textField] setStringValue:[pond name]];
[[self imageView] setObjectValue:[pond sidebarIconImage]];
Logging the font after the call to setFont shows the correct font. The call to -setStringValue: (and to set the icon) both work.
At this point I am baffled and figure I am missing something obvious about view based outline view drawing but I have no clue what. Nor can I glean anything from Google or StackOverflow. If anyone could help me I'd be most grateful.
Kind regards,
Matt
--
http://mattmower.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden