Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Getting Selected NSTextView Line

Getting Selected NSTextView Line
Thread Tools
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Aug 16, 2005, 12:42 PM
 
Im doing some drawing in an NSTextView, and I'd like to get the rect of the currently selected line (when there is no selection, so just where the cursor is). I've done some research and it seems I have to use the NSLayoutManager of the text view. This is where I'm completely stuck, it seems like lineFragmentRectForGlyphAtIndex:effectiveRange: could be useful, but after experimenting, I just can't seem to get it right.

Any help is appreciated,
Oliver
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Aug 16, 2005, 12:47 PM
 
I think this sample code is relevant.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Aug 16, 2005, 03:20 PM
 
Thanks for the link, seems very useful. One problem I am having getting my head around is finding the range for where the cursor is (by cursor, I mean the I-Beam, not the mouse). In the code you linked to, it seems to use:

glyphIndex = [layoutManager glyphIndexForPointoint inTextContainer:textContainer];

But I can't find anything to help with my problem.

Thanks
     
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Aug 17, 2005, 04:53 PM
 
Fixed it, thanks.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:26 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2