On 21 Nov 2013, at 10:55 AM, Andrew Arrow wrote:
> How do I make a drag select on a NSTextView with an NSAttributedString
> that contains a 2 column NSTextTable, only select the text in the 1st
> column?
>
> You can see a video of the mac app skype doing this here:
>
> https://dl.dropboxusercontent.com/u/2510380/skype.mov
What leads you to believe that Skype is using the very specific technique you
ask about? Did you point a debugger at it? Disassemble? From what I see in the
animation, your guess looks very unlikely.
Assuming your actual goal is to select across disjoint text containers:
A quick examination of the API persuades me that the option isn't available in
a single NSTextView. There's no royal road. I'm sure there's some way to do it
in HTML/CSS/JavaScript, but I can't help you there.
What you can do is to divide the column into a series of NSTextViews. There is
a text-storage (attributed string) with the full contents of the column. It is
associated with one layout manager. Ask the layout manager for the height of
each block of text you want to put on its own row, and initialize a container
from it. Put each container into its own NSTextView.
See
(assuming Xcode documentation URLs work; it's Cocoa Text Architecture Guide >
Text System Organization > Creating Text System Objects > Your App Creates the
Objects Explicitly) Also TextSizingExample in the sample code.
My experiment shows that if you drag down from one text view to the next, the
selection spans the views. There's no question of the selection spilling out to
other views, because the text system never sees them.
This is the first thing that comes to mind, from WWDC ~2005. I haven't done
this sort of thing in years, and I'm probably missing some technique the kids
are using these days, with their bow ties and hipster music. I can imagine
doing something by hit-testing the table drags and being clever with the
setSelectedRange: family, but that's worse.
— F
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com