nstextview

How can I protect certain strings in NSTextView

In my application I'm using custom attributes to contain text I want to hide or unhide. When text is hidden, it contained as the value (as NSAttributedString) of the custom attribute "Hidden", for example, in a special character sequence (for example (H)). This all works super. I don't about saving the custom attribute when I save the...

How do I use Core Data with the Cocoa Text Input system?

Hobbyist Cocoa programmer here. Have been looking around all the usual places, but this seems relatively under-explained: I am writing something a little out of the ordinary. It is much simpler than, but similar to, a desktop publishing app. I want editable text boxes on a canvas, arbitrarily placed. This is document-based and I’d real...

Setting the font of an NSTextView

I am subclassing NSTextView to set it's default font: PTNfoEditField.h @interface PTNfoEditField : NSTextView { } @end PTNfoEditField.m @implementation PTNfoEditField -(id)init { if(self = [super init]) { [[self textStorage] setFont:[NSFont fontWithName:@"Courier" size:10]]; } return self; } @end However, ...

Faking an NSTextField using an NSTextView to get nice coloring?

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 g...

Set Text in NSTextView with NSData

Hi folks! I have an instance of NSData that I stored from a previous run of my application. I want to set an NSTextView's text using this data. It is RTF and I can't figure out how to do this. Any ideas or suggestions? It needs to be done with code and not Interface Builder. Thanks ...

How to disable word-wrap of NSTextView?

NSTextView does word-wrap by default. How can I disable this? I'm making a JSON code viewer, so I have to disable this. ...

NSTextView Insert Line Break

Hi Folks! I have an NSTextView that I need to insert a line break in. The code looks like this: NSString *myString = @"test" [myTextView insertText:myString]; /**** INSERT LINE BREAK HERE ****/ [[myTextView textStorage] insertAttributedString:MY_ATTRIBUTED_STRING atIndex:myString.length]; Anybody have any idea how to do this? ...

Creating a view with draggable text elements

Hi all, I am trying to create a view for a kind of brainstorming application like, for example, OmniGraffle, with elements that contain textviews and can be dragged around. (Also, the should be connectable with arrows, but that is not (yet) the problem) I did my homework and searched via google and read books about cocoa, but there see...

Catching TextDidChange or DidEndEditing of an NSTextView instead of an NSTextField

It seems that NSTextView does not have the notification DidEndEditing and TextDidChange (which both exist for an NSTextField). Is there any similar functionality I can get out of the NSTextView? If not is there no way to know when the user has edited the text of the NsTextView? ...

Search For NSAttributedString with custom attribute and Remove it? How to?

I have a placeholder string, a space character, in an NSTextView that I want to remove at a future time. My strategy is to assign the NSAttributedString a custom attribute and perform a search on the [NSTextView string] removing it. So far, I haven't found a good way to do this, outside of going through [NSTextStorage attributeRuns]. ...

Save NSTextView in NSMutableArray and read it

Hi Everyone! My question is the following, I have an NSTextView and I want to do 2 things : First save this textview in an NSMutableArray and assign a X,Y position to it in this array. Secondly, get this textview from the NSMutableArray and display it at the position I've set when I saved it in the array. Anyone have an idea of ho...

NSTextView: How to be notified when user pastes data?

I need to be notified when the user pastes data into an NSTextView in order to strip it of any disallowed data types (url links, etc). I don't want to use NSTextStorageDelegate's textStorageDidProcessEditing: because it is called when the user is just typing. How can I be notified of pastes only? ...

Generate a Custom PDF layout from an NSTextView?

Problem: Users need a pdf document generated in a set font and size and a fixed number of lines per page (each line numbered). Users are entering text into a standard NSTextView. If I just choose File->Print, the default layout will render as much text as will fit onto the page, more than just 25 lines. I understand that I can use an...

Padding around an NSTextView in an NSScrollView

I'd like to provide a few pixels of padding around an NSTextView inside of an NSScrollView. I've reviewed this post and using setTextContainerInset does the trick for the left, right, and bottom margins. But as soon as the text scrolls the top buffer is lost. Same thing with overriding textContainerOrigin. Another answer in that post sta...

NSTextViews and background layout

Hi, I've got a really weird crash on Leopard (not on Snow Leopard) concerning NSLayoutManager, NSTextView and the background layout feature. My application is 64-bit garbage collected and that seems to be the root of the problem. I've established that the crash happens like this: 1) the system decides to do some background layout on s...

NSTextView - using initWithHTML with tables

Hi, I'm trying to format some text in NSTextView to be placed in a single line with black background. One piece of text needs to be left aligned, the other piece (but still in the same line) needs to be centered. NSString *header = [NSString stringWithFormat: @"" "<table style=\"width: 100%; background: black; " ...

NSTextView Subclass - A4 Paper Look

Hello, I am thinking about modifying my NSTextView to look like an A4 sheet. So basically a line drawn around the textContainer, but I don't know how this could be done... Just in case no one understands what I mean, I've attached a screenshot :P http://web.me.com/david.schiefer/a4.png Thanks :) ...

NSTextView hangs while typing

Hi, I'm experiencing hangs while typing on an NSTextView. The NSTextView is on a window that I run modally. [NSApp runModalForWindow:[self window]]; I'm not really sure how, but I think it has something to do with the scrollbars. When I click the "enter key" until it starts scrolling down, it always hangs. Can you please help me how ...

NSTextView: loading RTF, view does not update correctly until mouse is moved over the control

I have a pretty simple window that contains an NSTextView. I'm calling readRTFDFromFile: to load and display an rtf file on disk. I'm calling this from within the awakeFromNib handler. When the view appears on screen it only partially displays the contents of the rtf, the button portion of the view is blank/white. However, when the mous...

NSTextView overlay causes oddities with first responder status

I have an NSTextView in an NSScrollView, and I am programmatically inserting an NSView subclass as a subview of the NSTextView. This NSView acts as an overlay, superimposing graphical information about the text beneath it. I thought it was working quite well until I noticed that the text view does not respond to right clicks. Other op...