nstextview

How do I use SPACE instead of TAB in NSTextView

此生再无相见时 提交于 2019-12-10 03:39:46
问题 I just know how to modify the tab width in NSTextView NSMutableParagraphStyle *paragraphStyle = [[self defaultParagraphStyle] mutableCopy]; [paragraphStyle setTabStops:[NSArray array]]; [paragraphStyle setDefaultTabInterval: tabWidth]; But, is there any way to use 4 SPACES instead of TAB in NSTextView? 回答1: Well, it's late, but I'll post my answer in case some other poor soul is struggling with this. I''ve been struggling with this all day, and finally found the answer at cocoabuilder In

How do I make NSTextView grow with text?

て烟熏妆下的殇ゞ 提交于 2019-12-09 23:08:24
问题 I am creating a simple word processor where it's possible for the user to add a text box to an NSView , similar to the function in Pages. The problem is that when it's added it will stay the same size no matter how much text the user inputs. I want it to grow as the user inputs text, I have tried with this GitHub project but when I use it the text field only expands when I have deleted all the text, as if the code doesn't react before the textDidEndEditing method. After working a bit with

Setting the Line Height/ Line Spacing in an NSTextView

你说的曾经没有我的故事 提交于 2019-12-09 11:47:37
问题 How would I set the Line Height or Line Spacing in an NSTextView (i.e. how tall each line is, or how much space is between each line)? 回答1: Use the - (void)setDefaultParagraphStyle:(NSParagraphStyle *)paragraphStyle method in your NSTextView. Documentation on NSParagraphStyle Documentation on NSMutableParagraphStyle There is a setLineSpacing: method in NSMutableParagraphStyle. There are also methods relating to line height, the methods under "Setting Other Style Information" in the

Saving NSAttributedString with NSTextAttachment into file. How to?

人盡茶涼 提交于 2019-12-09 07:14:28
问题 I have a NSTextView , which may contains rich text or rich text with image as NSTextAttachment . There is how I adds attachment: NSImage *image = [NSImage imageNamed:@"image"]; NSTextAttachmentCell *attachmentCell =[[NSTextAttachmentCell alloc] initImageCell:image]; NSTextAttachment *attachment =[[NSTextAttachment alloc] init]; [attachment setAttachmentCell: attachmentCell ]; NSAttributedString *attributedString =[NSAttributedString attributedStringWithAttachment: attachment]; [[aTextView

Auto scrolling to the end of NSTextView

て烟熏妆下的殇ゞ 提交于 2019-12-08 11:56:27
问题 I have a NSTextView on which I am appending console logs. I have implemented this UI in XIB file with scroll views. When my application appends the console logs in the text view, I want the scroll bar to automatically go to the end of the textview. I could not find any property in XIB editor. Any idea how can I achieve this? @property(nonatomic, strong) IBOutlet NSTextView *logTextView; [[self.logTextView textStorage] beginEditing]; [[[self.logTextView textStorage] mutableString] appendString

Core Data bindings with subviews and multiple NIBs

不想你离开。 提交于 2019-12-07 18:19:28
I have a document-based Core Data app. My main Core Data entity has several string fields, most of which are bound to NSTextFields, but one is bound to an NSTextView. I am using the technique for view switching (with multiple view controllers) as explained in the Hillegass book. All of my subviews are controlled by a ManagedViewController, my subclass of NSViewController that has a managedObjectContext field. My subview exists in a separate nib file. For some reason, the bindings I have set up in that nib are not working--but if I set up the widgets and the bindings in the exact same way in

NSLineBreakByTruncatingTail scrolls text when set as a paragraph style in NSTextView

佐手、 提交于 2019-12-07 17:31:59
问题 I have a NSTextView , which is supposed to be fixed size. When the text comes to the bottom line and to the right edge of the designated frame I need to set the NSLineBreakByTruncatingTail in order to present user with elliptic signs and disable further typing. When I do this through setting a paragraph style on textStorage of NSTextView the text scrolls up and I see only the last line with elliptic signs in the end. My question is how to prevent NSTextView from scrolling when changing its

How to have a NSTextView with a different font size just for printing?

筅森魡賤 提交于 2019-12-07 15:46:28
I have a NSTextview that only shows good when the text is set to at least 16 in size, but that is too big for printing. How to have a NSTextView with a different font size just for printing ? I have digged into NSPrintInfo but got no result so far. Thanks Here's an example: // Create another text view just for printing var printTextView = NSTextView(frame: NSMakeRect(0, 0, 528, 688)) // A4 // Add a modified version of your attributed string to the view printTextView.textStorage!.mutableString.appendString(myAttributedStringWithAdjustedSize) // Get printing infos let sharedInfo = NSPrintInfo

How to handle NSTextView preferences (spelling and grammar, substitutions,…)

◇◆丶佛笑我妖孽 提交于 2019-12-07 09:57:00
问题 The NSTextView class allows the user to dis-/enable features like "spelling while typing" with the context menu (right click). But when I use a NSTextView in my own app, those preferences are not saved automatically by the text view itself, which means that I have to save them separately - right? Now I also want to allow the user to change those settings in my app preferences (like in TextEdit). What I do is to save the text view preferences in the user defaults, which means that every time

NSTextView's insertText method is deprecated in OS X v10.11. What is the replacement?

独自空忆成欢 提交于 2019-12-07 09:30:19
问题 I saw in the AppKit API Reference that the insertText method is deprecated in OS X v10.11. What am I supposed to use as a replacement? 回答1: The documentation says - (void)insertText:(id)aString This method is the means by which text typed by the user enters an NSTextView . See the NSInputManager class and NSTextInput protocol specifications for more information. ... In NSTextInput there is a note: IMPORTANT NSTextInput protocol is slated for deprecation. Please use NSTextInputClient protocol,