3
嗯,我得到了這個:http://d.pr/i/jItMNSTextField - 如何更改文本/編輯區域的大小和位置?
我顯然想要移動文本,並離開左邊緣。我有繪製背景的NSTextField的子類,但我無法找到它。
嗯,我得到了這個:http://d.pr/i/jItMNSTextField - 如何更改文本/編輯區域的大小和位置?
我顯然想要移動文本,並離開左邊緣。我有繪製背景的NSTextField的子類,但我無法找到它。
明白了。兩者都需要被覆蓋。
- (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];
}
所以我設法定位文本,因爲我想不編輯時。但是,當我開始編輯文本時,它會移回到左上角!我不知道如何定位fieldEditor,我嘗試覆蓋NSTextFieldCell中的各種方法。 –