Questions tagged [nstextview]

NSTextView is the front-end class to MacOS's Application Kit text system. It draws the text managed by the back-end components and handles user events to select and modify its text. While NSTextView is a subclass of NSText—which declares the most general Cocoa interface to the text system—NSTextView adds major features beyond the capabilities of NSText.

Text views are user interface objects instantiated from the NSTextView class. Text views typically display multiple lines of text laid out in paragraphs with all the characteristics of sophisticated typesetting. A text view is the main user interface to the Cocoa text-editing system. It handles user events to provide text entry and modification, and to display any font, including those of non-English languages, with arbitrary colors, styles, and other attributes.

The Cocoa text system supports text views with many other underlying objects providing text storage, layout, font and attribute manipulation, spell checking, undo and redo, copy and paste, drag and drop, saving of text to files, and other features. NSTextView is a subclass of NSText, which is a separate class for historical reasons. You don’t instantiate NSText, although it declares many of the methods you use with NSTextView. When you put an NSTextView object in an NSWindow object, you have a full-featured text editor whose capabilities are provided “for free” by the Cocoa text system.

871 questions
6
votes
2 answers

Why cannot NSTextView for a weak reference?

I noticed than in OSX, the NSTextView cannot for a weak refference (if you try to link it weak, you will get) Cannot form weak reference to instance (0x600000122da0) of class NSTextView. It is possible that this object was over-released, or is in…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
6
votes
3 answers

NSTextView Insert Line Break

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]…
Bob
  • 61
  • 1
  • 2
6
votes
2 answers

Disable editing in NSTextView

I am trying to disable editing in NSTextView but there doesn't seem to be any option there.All the other types have enabled property which when set to false are non editable but is there any for NSTextView?
Zeist
  • 635
  • 1
  • 7
  • 17
6
votes
1 answer

How to set the text of an NSTextView in Xamarin Mac?

OK, from the "I never expected THIS to be the hard part" department: how do I set the text of a NSTextField in Xamarin Mac? NSTextView view = new NSTextView(new RectangleF(0, 500, 200, 40)); view.StringValue = "Foo"; does not compile (no method…
Joe Strout
  • 2,634
  • 2
  • 28
  • 39
6
votes
2 answers

Growing NSTextView to fit contents is clipping last line of text

I'm trying to create an NSTextView that grows vertically as the user types and scrolls once the height has reached a maximum. This is similar to the text view in Messages works. My first attempt uses the delegate to listen for text changes and…
ppilone
  • 1,082
  • 1
  • 10
  • 16
6
votes
1 answer

NSTextview: How do I get the glyph rect of the insertion point ? Custom TextView?

I can't seem to find any documentation about how to get the rect of the insertion point. I'm trying to display a view (like auto-complete) directly below the text caret / insertion point I'm considering making a custom textview but if i could…
Hovanky
  • 303
  • 1
  • 3
  • 15
6
votes
0 answers

Accent remains separated in NSTextView while typing

I use NSTextView in my Cocoa app. I press Option-E, the text view displays an acute accent in a yellow highlight box, indicating that it is marked text, rather than final input. When the I type the next character, the text view must display it as a…
Igor
  • 880
  • 1
  • 7
  • 11
6
votes
2 answers

Detect Enter/Tab/Up/Down keys in NSTextView?

Cocoa noob here. I'm wondering how I can capture the Enter and tab keys onKeyDown whilst the user is typing in an NSTextView? Thanks!
Connor
  • 4,138
  • 8
  • 34
  • 51
6
votes
2 answers

How to set font in NSTextView?

As simple as it seems, I simply CANNOT find ANY way to do that (setFont: is not working) : Have a NSTextView Set its font to some NSFont. Hint : (Pretty obvious, but whatever... ) IF the user adds any text, the new text is supposed to 'inherit'…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
5
votes
2 answers

NSTextView doesn't call controlTextDidChange:

I have a class ("TextEditorViewController") within there is a NSTextView ("textView") Object. I've connected it with the NSTextView in my .xib file. Here my .h file: #import @interface TextEditorViewController : NSObject…
qwertz
  • 14,614
  • 10
  • 34
  • 46
5
votes
1 answer

Getting filename and path from nsfilewrapper / nstextattachment in NSAttributedString

I have a basic NSTextView with rich text and graphics enabled (in IB). What I'd like to get is the path and filename of any images dragged in so I can pass those to another class. I'm new to NSAttributedString but I've got a loop using…
5
votes
1 answer

Creating an in-app link in NSTextView

I found this little snippet which allows one to create links from text in an NSTextView: -(void)setHyperlinkWithTextView:(NSTextView*)inTextView { // create the attributed string NSMutableAttributedString *string =…
Roger
  • 4,737
  • 4
  • 43
  • 68
5
votes
2 answers

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

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…
brutella
  • 1,597
  • 13
  • 26
5
votes
3 answers

How can I set the color of ALL text in a NSTextView (rather than just text typed afterwards)

I want to change the color of ALL the text in a NSTextView. Currently, I have code doing this: NSMutableDictionary* fontAttributes = [[NSMutableDictionary alloc] init]; [fontAttributes setObject: newColour…
Graham Lea
  • 5,797
  • 3
  • 40
  • 55
5
votes
1 answer

NSTextList formatting

I'm trying to figure out how to use NSTextList but have found little useful information online aside from this SO question and the comment in this blog. Using this I have been able to create a crude example to figure it out: let textView =…
santi.gs
  • 514
  • 3
  • 15