I have a bunch of NSTextView
s 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?
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
.