Reputation: 3573
How can I make programmatically an NSTextView
scroll to the cursor position?
Upvotes: 1
Views: 853
Reputation: 3573
This should work
NSUInteger cursorPosition;
cursorPosition = [[[self.textView selectedRanges] firstObject] rangeValue].location;
[self.textView scrollRangeToVisible:NSMakeRange(cursorPosition, 0)];
Upvotes: 3