Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monitoring NSTextView Attributes




On Apr 11, 2006, at 1:56 PM, Scott Thompson wrote:

We have code that likes to monitor the current selection in an NSTextView and update the attributes of a panel (text color, background color, font size, things like that) as the user enters text.

Our code is currently observing NSTextStorageDidProcessEditingNotification and NSTextViewDidChangeSelectionNotification. In response to those we use calls like rangeForUserCharacterAttributeChange and attributesAtIndex:effectiveRange: to figure out what attributes the inspector should display.

The difficulty with this approach is that it seems to trip up Japanese text entry. The glyphs that the user types go in, but at the point where the user is supposed to be able to combine glyphs, choose alternate forms, and things like that, we don't give them that opportunity.

I guess one of the routines we use to discover the current attributes is "ending" the inline editing session.


The issue is that rangeForUserCharacterAttributeChange usually is used to determine a range over which to change character attributes, and in order to do that properly inline editing needs to be ended. One idiom you might try is


NSRange charRange = ([textView hasMarkedText] ? [textView markedRange] : [textView rangeForUserCharacterAttributeChange]);

Douglas Davidson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Monitoring NSTextView Attributes (From: Scott Thompson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.