I have a Cocoa application based on a Mac OS X document.
One of the functions that I have in my application is a list of text elements that you can double-click to edit. When the user double-clicks on one of the text elements, I place the current text box of the window fieldEditoron the clicked text element to allow editing.
Everything is working fine, except for one problem. I canβt figure out how to make the text box fieldEditor clip + scroll , and not wrap its text. Here it looks like this:

See how the text wraps in the second line? I do not want it. I would like it to remain one line that scrolls (and the cropped one appears).
Here is an example of how it works correctly on a list item that has less text:

Here is what I am trying in my controller:
NSWindow *win = [listItemView window];
NSText *fieldEditor = [win fieldEditor:YES forObject:listItemView];
[fieldEditor setFont:[TDListItemView titleFont]];
[fieldEditor setAlignment:NSLeftTextAlignment];
[fieldEditor setDrawsBackground:YES];
[fieldEditor setBackgroundColor:[NSColor whiteColor]];
[fieldEditor setString:str];
[fieldEditor setDelegate:self];
[fieldEditor selectAll:nil];
if ([fieldEditor isKindOfClass:[NSTextView class]]) {
NSTextView *tv = (NSTextView *)fieldEditor;
NSMutableParagraphStyle *style = [[[tv defaultParagraphStyle] mutableCopy] autorelease];
[style setLineBreakMode:NSLineBreakByClipping];
[tv setDefaultParagraphStyle:style];
}
CGRect r = [self fieldEditorRectForBounds:[listItemView bounds] index:idx];
[fieldEditor setFrame:r];
[fieldEditor setNeedsDisplay:YES];
[[self view] addSubview:fieldEditor];
[win makeFirstResponder:fieldEditor];
Note that the part is in the middle: I check to see if this fieldEditorinstance is NSTextViewto invoke a method setDefaultParagraphStyle:on it. This is my attempt to get fieldEditorits text for the clip - using the value NSLineBreakByClipping. This has no effect. And I'm not even sure if this is what I have to do to scroll fieldEditoron one line.
, , -fieldEditorRectForBounds:index:, , ( 14,0 ).
, fieldEditor / ?
:
[[tv textContainer] setHeightTracksTextView:YES];
[[tv textContainer] setWidthTracksTextView:YES];
fieldEditor, . , , , + .: (
:
NSStringDrawingUsesLineFragmentOrigin
options::
-[NSAttributedString drawWithRect:options:attributes:]
NSText, NSAttributedString. , NSText.