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
0
votes
1 answer

NSTextView : contents are gone when scrolling, and shown when on mouseover

So this is my issue : I've got an an NSTextView with lots of content in it (white foreground on black background, if that matters), residing in a Sheet (triggered with beginSheet:modalForWindow:). The thing is that, when the I'm scrolling, the…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
-1
votes
0 answers

Custom find-bar view in NSScrollView

Is there a way to insert a custom Find bar in NSScrollView, so that it plugs in properly with the find-system of Cocoa. I did some digging around NSTextFinder, NSTextFinderClient and NSTextFinderClient. Seems like they facilitate various search…
Kaunteya
  • 3,107
  • 1
  • 35
  • 66
-1
votes
1 answer

NSTextView – text disappears while adding a new line

I've recently met a problem that once I'm adding a new line in an NSTextView, the least visible line disappears for a moment. The same happens when I'm deleting a line. The problem occurs even in a newly created Xcode project with pure NSTextView.…
-1
votes
1 answer

Inserting text in NSTextView crashing on macOS 10.12 and 10.13

I've got the following code that inserts a new NSAttributedString into NSTextView. This works fine on all versions of macOS 10.14+, however when the NSTextView is empty, the following code causes an immediate crash when inserting any amount of…
strangetimes
  • 4,953
  • 1
  • 34
  • 62
-1
votes
1 answer

NSTextField: error on calling completions by .complete(nil) in swift 5

I'm using NSTextField with complections and they work fine by pressing F5 key. But I have to call complections programmatically and I'm using complete(:) for this, but I get an error and crash every time I I tried to call…
-1
votes
1 answer

Looking for example of how to display text in an NSWindow programmatically?

I am trying to display text in a HUD style semi-transparent window. I have got the code for the window all set up, but I have been scouring the documents for two days now and haven't come up with a way that works to actually display text in the…
Chris Norman
  • 225
  • 2
  • 11
-1
votes
1 answer

NSTextView, how do I make a typewriter?

The user has made an opinion, but I don't know how to achieve it. The user hopes to send a "DaDa" sound like a typewriter in the NSTextView, when the keyboard is entered with the keyboard, and the default setting is not found. How do I finish this…
Simon
  • 438
  • 4
  • 14
-1
votes
2 answers

Using DispatchQueue to fix Delay in updating NSTextView from switch statement

I am using a switch statement in Swift 3 (Xcode 8.3.2) to parse a range of JSON objects (using SwiftyJSON) for a macOS app. For each case I am trying to print an update to a textView that is declared in the same class (NSViewController) and bound…
-1
votes
1 answer

Equivalent for Windows messages (EM_LINEFROMCHAR/EM_LINEINDEX) in OSX/Cocoa

ALL, Is there an equivalent for EM_LINEFROMCHAR/EM_LINEINDEX Windows notification in OSX/Cocoa? I couldn't find anything looking here. Basically I'm looking to give a position and receive (x,y) coordinate inside the view.
Igor
  • 5,620
  • 11
  • 51
  • 103
-1
votes
1 answer

Restore the visual state of an NSAttributedString after having clicked on it

I need to restore the visual state of an NSAttributedString after having clicked on it. My NSAttributedString contains links attributed to ranges. In this example the text "@user" has a a link to "htpp://somesite.com/": let text = "Hey @user!" let…
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
-1
votes
2 answers

NSTextView backed by core data

I have a NSTabViewController with a NSTextView in one tab. The text is saved in core data. I save the text when the view disappears. override func viewWillDisappear() { super.viewWillDisappear() self.saveText() } But how do I save the text…
user965972
  • 2,489
  • 2
  • 23
  • 39
-1
votes
1 answer

is there a method available for Xcode's yellow find result rectangle?

Possible Duplicate: Search-like highlighting in NSTextView I thought i read here months ago that there is a cocoa method for this feature, but now i can't find it, or search for it's too many common words. nothing yeilded in NSTextView, or NSText…
lulu
  • 669
  • 10
  • 26
-2
votes
1 answer

Swift NSAttributedString: kCTForegroundColorAttributeName vs NSAttributedString.Key.foregoundColor

I have a CFMutableAttributedString set with attributes of key kCTForegroundColorAttributeName and value of type CGColor. let attrString = NSMutableAttributedString(string: "foo bar") let range = CFRange(location:0,…
system64
  • 909
  • 1
  • 11
  • 27
-2
votes
1 answer

Rounded corners on an NSTextView/NSScrollView?

There is a similar question already on here but it is in objective C. The answer in objective C is apparently: [self.textView.layer setCornerRadius:10.0f]; I've tried translating this into Swift a few different ways. I'm guessing I want something…
SuperHanz98
  • 2,090
  • 2
  • 16
  • 33
-2
votes
1 answer

Anyone know what cause this crash:"[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector"?

Recently I use NSTextTable draw table. I want change some attribute of selected block,so save selected paragraphs into dictionary. After I copy the block of paragraph, once I call method [NSTextTableBlock setBorderColor:], raise an…
John Chen
  • 27
  • 6
1 2 3
58
59