0

I am trying to find a way to scrool down at the end of a NSTextField automatically. The textField is updated in a loop so I wanted to know how to make it display the last text entered each time by scrolling down.

Here is my code:

var tmp = consoleView.stringValue.utf16Count
if tmp >= 25000
{
    consoleView.stringValue = "";
}
consoleView.stringValue = //[..longStringHere..]
consoleView.//SCROLLDOWN

I saw there are some answers in objective-c but I never did any program in it so I don't understand it well...

Thank you

P1kachu
  • 1,077
  • 3
  • 11
  • 33

1 Answers1

0

For the scrolling I think you would rather need a NSTextView.

textView.scrollRangeToVisible(
      NSRange(location: countElements(textView.string!), length: 0))
Mundi
  • 79,884
  • 17
  • 117
  • 140
  • I tried to do it with a NSTextView but I wasn't able to edit the text anymore (no .stringValue or.text found...) – P1kachu Aug 16 '14 at 08:28
  • `NSTextView` is a subclass of `NSText`. You can retrieve the text without attributes via its property `string`, as shown above. – Mundi Aug 16 '14 at 09:24