views:

837

answers:

1

Hello everybody, I'm making a Cocoa application and I can't figure out how to do something.

I want to make an NSTextField with a custom look like the one in Wallet :

Wallet screenshot.

I figured out how to change the NSTextField size but I don't know how to change the font and it size. I subclassed NSTextFieldCell like this but it doesn't work, the font is not changed if I don't choose a system font and the size only change line height but not characters height.

Header file :

//  VLTextFieldCell.h
//  Cutie's Locker
//
//  Created by Vivien Leroy on 08/07/09.
//  Copyright 2009 Vivien Leroy. All rights reserved.

#import <Cocoa/Cocoa.h>

@interface VLTextFieldCell : NSTextFieldCell {
}
@end

Class file :

//  VLTextFieldCell.m
//  Cutie's Locker
//
//  Created by Vivien Leroy on 08/07/09.
//  Copyright 2009 Vivien Leroy. All rights reserved.
//

#import "VLTextFieldCell.h"


@implementation VLTextFieldCell

- (NSFont *)font
{
    return [NSFont fontWithName:@"Lucida Grande" size:16.0];
}

@end
+5  A: 

To change the font of an NSTextField, change its font in Interface Builder using the Font Panel, or via -setFont: at runtime.

It is not necessary to subclass NSTextField or NSTextFieldCell simply to use a different font.

Jim Correia
Oh right… I was looking for the Font setting… Didn't think about the +T Font Panel.Thanks ;)
Fantattitude