2012-11-18 1 views
3

글쎄,이있어 : http://d.pr/i/jItMNSTextField - 텍스트/편집 영역의 크기와 위치를 변경하는 방법?

분명히 텍스트를 왼쪽 가장자리에서 아래로 이동하고 싶습니다. 배경을 그릴 NSTextField 하위 클래스가 있지만이 찾을 수 없었어요.

+0

그래서 편집하지 않을 때 텍스트를 배치 할 수있었습니다. 그러나 텍스트 편집을 시작하면 다시 왼쪽 상단으로 이동합니다! fieldEditor의 배치 방법을 모르겠다. NSTextFieldCell에서 다양한 메서드를 재정의하려고 시도했다. –

답변

5

알 수 있습니다. 둘 다 재정의해야합니다.

- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent 
{ 
    aRect.origin.y += 9; 
    aRect.origin.x += 10; 
    [super editWithFrame:aRect inView:controlView editor:textObj delegate:anObject event:theEvent]; 
} 

- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength 
{ 
    aRect.origin.y += 9; 
    aRect.origin.x += 10; 
    [super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; 
}