Thanks Corbin and Paul. I am using the windowWillReturnFieldEditor:toObject: delegate method, testing to see if anObject is a DeductionTable (a subclass of NSTextView), and testing to see if the first responder is an NSTextView, and then changing the textColor of the first responder to black. This changes the text to black before the user edits anything, so it works. Here is the code:

-(id)windowWillReturnFieldEditor:(NSWindow *)sender toObject: (id)anObject
{
if ([anObject isKindOfClass:[DeductionTable class]] && [[[deductionTable window] firstResponder] isKindOfClass:[NSTextView class]])
    {
NSTextView *firstResponder = (NSTextView *)[[deductionTable window] firstResponder];
                [firstResponder setTextColor:[NSColor blackColor]];
        return firstResponder;
    }
    return nil;
}

I do wonder about the efficiency of this though. It turns out that this method is called dozens of times for a single edit. Can this really be the right way to solve the problem?

On 4-Mar-09, at 1:04 AM, Paul Sanders wrote:

Thanks for this.  I think this would solve part of the problem (when
it was clicked on by the user), but not if the text edit field were
selected in some way other than a mouse click.

I thought about this a little bit too. It seems to me that the change in firstResponser is the key to this. I don't know how to trap this - I'm new
to Cocoa - but maybe that observation helps a bit.

Rgds - Paul.


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to