我正在尝试创建用户单击的输入文本框(点是用户单击的 NSPoint)。
现在我可以正常工作了,但是显示的输入框太小了。我想让它填满外部视图(以蓝色显示)。
// Text Storage
NSTextStorage *textStorage = [[NSTextStorage alloc] init];
[textStorage setFont:[NSFont fontWithName:@"Menlo" size:18]];
// Layout Manager
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
[textStorage addLayoutManager:layoutManager];
NSRect textViewBounds = NSMakeRect(point.x, point.y, NSWidth(self.window.frame), 50);
// Text Container
NSTextContainer *textContainer;
textContainer = [[NSTextContainer alloc]
initWithContainerSize:textViewBounds.size];
[layoutManager addTextContainer:textContainer];
// Text View
NSTextView *textView = [[NSTextView alloc] initWithFrame:textViewBounds];
// Of course text editing should be as undoable as anything else.
[textView setAllowsUndo:YES];
[textView setBackgroundColor:[NSColor blueColor]];
//[textView setDrawsBackground:NO];
[self addSubview:textView];
// Make the editing view the first responder so it takes key events and relevant menu item commands.
//[self.window setContentView:textView];
[self.window makeFirstResponder:textView];
我在这里想念什么?