Question

How can I make programmatically an NSTextView scroll to the cursor position?

Was it helpful?

Solution

This should work

NSUInteger cursorPosition;
cursorPosition = [[[self.textView selectedRanges] firstObject] rangeValue].location;
[self.textView scrollRangeToVisible:NSMakeRange(cursorPosition, 0)];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top