I'm trying to create an input text box where the user clicks (point is an NSPoint where the user clicked).
Right now I have it working, but the input box that's being displayed is too small. I'd like to have it fill up the outer view (showed in blue).
// 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];
What am I missing here?