Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequential selection among multiple NSTextViews

I have a bunch of NSTextViews that I would like to share a single selection. I basically want this to behave like selecting text on a web page, where there are multiple text views but you can drag to sequentially select text among them.

I found this document which states that it is possible to have multiple NSTextContainer objects sharing a single NSLayoutManager and thus share the selection. This is halfway to what I want, except for the fact that one NSLayoutManager can only have a single NSTextStorage object. I want each text view to have its own NSTextStorage so that each text view can have its own text, but I still want to be able to select text in multiple text views with one drag. Is this possible?

like image 799
indragie Avatar asked Feb 03 '13 00:02

indragie


1 Answers

There's no easy way to solve this problem (as I tried to find by asking this question). It involves all the mouse event handling and text selection calculations you'd expect, so I wrote the code and have open sourced it as INDSequentialTextSelectionManager.

like image 112
indragie Avatar answered Oct 02 '22 17:10

indragie