1

I have a text view and I would like to scroll it programmatically (along my video playback). I created an outlet in my ViewController:

@IBOutlet weak var scrollView: NSScrollView!

How can I use it to scroll to a specific character range of my text content?

Martin Delille
  • 11,360
  • 15
  • 65
  • 132

1 Answers1

0

Try use method scroll(to:) from NSClipView (doc) class.

let point: NSPoint ...
scrollview.documentView.scroll(point)
mbutan
  • 1,359
  • 2
  • 13
  • 23
  • My *scrollview* doesn't have *documentView* member. – Martin Delille Aug 16 '16 at 08:41
  • Sorry for the bad info: *scrollview* HAS a documentView member, but I want to scroll to a specific character range. Can I do it directly or is there a way to computer the character range to a NSPoint/NSRect value? – Martin Delille Aug 17 '16 at 08:14
  • try calculate origin position of specific character directly on your superview and scroll to this processed pos – mbutan Aug 17 '16 at 09:01