Re: Changing NSTableView cell immediately before editing [solved?]
Re: Changing NSTableView cell immediately before editing [solved?]
- Subject: Re: Changing NSTableView cell immediately before editing [solved?]
- From: "K. Darcy Otto" <email@hidden>
- Date: Wed, 4 Mar 2009 10:59:12 -0800
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 (email@hidden)
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:
This email sent to email@hidden