nstextview

How to disable word-wrap of NSTextView?

我们两清 提交于 2019-11-29 17:32:41
问题 NSTextView does word-wrap by default. How can I disable this? I'm making a JSON code viewer, so I have to disable this. 回答1: I got solution from: http://lists.apple.com/archives/cocoa-dev/2008/May/msg02396.html You have to set NSTextView's maximum width to very large number to make this work correctly. (Just copy maximum height) And enable horizontal scrolling of NSScrollView which is superview of the NSTextView. See these pictures: http://www.flickr.com/photos/47601728@N06/4759470529/ http:/

Premature line wrapping in NSTextView when tabs are used

天大地大妈咪最大 提交于 2019-11-29 16:29:29
I have a strange problem with NSTextView linewrapping after the 51st column if I enter a line of tabs. This only happens with tabs, not with any other character, which wrap correctly at the edge of the text view, not after the 51st character. This is easy to repeat. Create a blank project in XCode with a single window and just one NSTextView. The only non-default settings are that I have removed constraints, and used the old style autosize to autosize the textview so that it fills the window. I have written no code. Now run the application, open up the window so that is much wider than 51

Change the text of a NSTextView programmatically

末鹿安然 提交于 2019-11-29 11:07:55
问题 I can't find any parameter that seems to be related with the text value showed in a NSTextView . I understood that a NSTextView uses a complex structure (with NSLayoutManager etc...), but I can't find a valid way to modify the current text value. 回答1: The right method is "setString" [textView setString:@"the string"]; 回答2: Setting text on outlet textView Swift Xcode 8.0 textView.string = newString 回答3: Something like this: [textView setString:@"new value"]; 回答4: If you want to set attributed

Completely disable NSTextView spell checking

拟墨画扇 提交于 2019-11-29 06:14:44
How can I disable spell checking for an NSTextView? In particular, the red lines that are automatically drawn. I know about the "Continuous Spell Checking" option in Xcode, and every option I have found in the documentation related to spell checking doesn't seem to take the red lines away. Select NSTextView (doubleClick in IB on it because NSTextView is in NSScrollView by default or select it in Document Outline ) and go to Attributes Inspector -> Linguistics -> and uncheck Continous Spell Checking here: Result: rdelmar I don't know what you tried, but [self.textView

Set the placeholder string for NSTextView

回眸只為那壹抹淺笑 提交于 2019-11-29 04:22:41
Is there any way to set the placeholder string for NSTextView like that in NSTextField ? I have checked the property but couldn't find it. I have searched some questions but there isn't a proper explanation. soldiershin I found this answer online. Philippe Mougin made this. static NSAttributedString *placeHolderString; @implementation TextViewWithPlaceHolder +(void)initialize { static BOOL initialized = NO; if (!initialized) { NSColor *txtColor = [NSColor grayColor]; NSDictionary *txtDict = [NSDictionary dictionaryWithObjectsAndKeys:txtColor, NSForegroundColorAttributeName, nil];

NSString boundingRectWithSize slightly underestimating the correct height - why?

情到浓时终转凉″ 提交于 2019-11-29 03:41:29
I'm attempting to resize a text field / view automatically depending on its current width. In other words I want the width to stay constant but resize the height according to the text supplied to it. It seems to be working but for some reason is aligning to the bottom of my window despite efforts to manually move it back. Can anybody see what I'm doing wrong here? NSString *temp = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer vel felis nec massa ultricies blandit non id arcu. Sed enim est, facilisis a feugiat in, consectetur eget arcu. Aenean rutrum, lacus id euismod

'sizeWithFont:constrainedToSize:lineBreakMode:'is deprecated:

为君一笑 提交于 2019-11-29 02:52:46
Converting a project from iOS5.0 to iOS7 / iOS6 on Xcode 5. The code below is giving a compile time warning: 'sizeWithFont:constrainedToSize:lineBreakMode:'is deprecated: first deprecated in ios 7.0 - Use - boundingRectWithSize:options:attribiutes:context - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { self.lblHidden.frame = CGRectMake(58, 228, 945, 9999); self.lblHidden.text = detailShareObj.pDesc; CGSize size = [detailShareObj.pDesc sizeWithFont:self.lblHidden.font constrainedToSize:self.lblHidden.frame.size

How to resize NSTextView according to its content?

会有一股神秘感。 提交于 2019-11-29 02:48:50
问题 I am trying to set an attributed string within NSTextView. I want to increase its height based on its content, initially it is set to some default value. So I tried this method: I set content in NSTextView. When we set some content in NSTextView its size automatically increases. So I increased height of its super view that is NSScrollView to its height, but NSScrollView is not getting completely resized, it is showing scroller on right. float xCoordinate = 15.0; [xContentViewScroller setFrame

Scrolling NSTextView to bottom

回眸只為那壹抹淺笑 提交于 2019-11-29 02:04:48
I'm making a little server app for OS X and I'm using an NSTextView to log some info about connected clients. Whenever I need to log something I'm appending the new message to the text of the NSTextView this way: - (void)logMessage:(NSString *)message { if (message) { self.textView.string = [self.textView.string stringByAppendingFormat:@"%@\n",message]; } } After this I'd like the NSTextField (or maybe I should say the NSClipView that contains it) to scroll down to show the last line of its text (obviously it should scroll only if the last line is not visible yet, in fact if then new line is

Faking an NSTextField using an NSTextView to get nice coloring?

梦想与她 提交于 2019-11-28 23:16:47
问题 Trying to change the selected text background color for an NSTextField (we have a dark UI, and selected text background is almost the same as the text itself), but only NSTextView seems to allow us to change this. So we're trying to fake an NSTextField using an NSTextView, but can't get text scrolling to work the same. The closest we get is with this code: NSTextView *tf = [ [ NSTextView alloc ] initWithFrame: NSMakeRect( 30.0, 20.0, 80.0, 22.0 ) ]; // Dark UI [tf setTextColor:[NSColor