FROM : John Stiles
DATE : Tue Apr 29 19:20:10 2008
Really? Does this actually work?
I needed to find word boundaries to implement a Find panel which
supports searching for "Whole Words" and I ended up using
UCFindTextBreak based on advice from this list. It was a pain to
implement (since it's not designed to mesh with Cocoa at all).
Graham Cox wrote:
> NSTextView has this:
>
> - (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange
> granularity:(NSSelectionGranularity)granularity
>
> So if the proposedSelRange is a zero-length range at the character
> index determined before, and granularity is NSSelectByWord, it should
> return the range of the word.
>
> hth,
>
> G. (still guessing ;-)
>
>
> On 28 Apr 2008, at 8:06 pm, Ying Bian wrote:
>> Graham,
>>
>> Thanks for your reply! But how can I "find the range of the word" given
>> the glyph index? I just can not find an API doing so.
>>
>> So I don't think this is the underlying implementation. Any comments
>> from others?
>>
>> On Mon, Apr 28, 2008 at 2:51 PM, Graham Cox <graham.<email_removed>>
>> wrote:
>>> I imagine it uses some API such as NSLayoutManager's:
>>>
>>> - (NSUInteger)glyphIndexForPoint:(NSPoint)point
>>> inTextContainer:(NSTextContainer *)container
>>> fractionOfDistanceThroughGlyph:(CGFloat *)partialFraction
>>>
>>>
>>> One you have the glyph index you can find the range of the word it
>>> belongs
>>> to.
>>>
>>> One you have the string of the word it belongs to, you can look it
>>> up in
>>> dictionary.app using the Application Services API.
>>>
>>>
>>> hth, though I am guessing to some extent.
>>>
>>>
>>>
>>> G.
>>>
>>
>> --
>> B.Y.
>> _______________________________________________
>>
>> Cocoa-dev mailing list (<email_removed>)
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/graham.<email_removed>
>>
>>
>> This email sent to graham.<email_removed>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Tue Apr 29 19:20:10 2008
Really? Does this actually work?
I needed to find word boundaries to implement a Find panel which
supports searching for "Whole Words" and I ended up using
UCFindTextBreak based on advice from this list. It was a pain to
implement (since it's not designed to mesh with Cocoa at all).
Graham Cox wrote:
> NSTextView has this:
>
> - (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange
> granularity:(NSSelectionGranularity)granularity
>
> So if the proposedSelRange is a zero-length range at the character
> index determined before, and granularity is NSSelectByWord, it should
> return the range of the word.
>
> hth,
>
> G. (still guessing ;-)
>
>
> On 28 Apr 2008, at 8:06 pm, Ying Bian wrote:
>> Graham,
>>
>> Thanks for your reply! But how can I "find the range of the word" given
>> the glyph index? I just can not find an API doing so.
>>
>> So I don't think this is the underlying implementation. Any comments
>> from others?
>>
>> On Mon, Apr 28, 2008 at 2:51 PM, Graham Cox <graham.<email_removed>>
>> wrote:
>>> I imagine it uses some API such as NSLayoutManager's:
>>>
>>> - (NSUInteger)glyphIndexForPoint:(NSPoint)point
>>> inTextContainer:(NSTextContainer *)container
>>> fractionOfDistanceThroughGlyph:(CGFloat *)partialFraction
>>>
>>>
>>> One you have the glyph index you can find the range of the word it
>>> belongs
>>> to.
>>>
>>> One you have the string of the word it belongs to, you can look it
>>> up in
>>> dictionary.app using the Application Services API.
>>>
>>>
>>> hth, though I am guessing to some extent.
>>>
>>>
>>>
>>> G.
>>>
>>
>> --
>> B.Y.
>> _______________________________________________
>>
>> Cocoa-dev mailing list (<email_removed>)
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/graham.<email_removed>
>>
>>
>> This email sent to graham.<email_removed>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>






Cocoa mail archive

