I've tried two different approaches. The first thing I tried was to make may
app-delegate the delegate for my window and then implement
-windowWillReturnFieldEditor:toObject:.
- (void)awakeFromNib
{
_fieldEditor = [NSTextView new];
[_fieldEditor setFieldEditor:YES];
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor redColor],
NSBackgroundColorAttributeName, /* something obvious so I can see it */
[NSColor yellowColor],
NSForegroundColorAttributeName,
nil];
[_fieldEditor setSelectedTextAttributes:attributes];
}
- (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client
{
if ( [client isKindOfClass:[NSTextField class]] )
{
return _fieldEditor;
}
return nil;
}
Next, I tried something I found in a blog via Google at
http://www.ff00aa.com/fr/archives/2009/02/28/9969-changing-the-selected-text-s-color-for-an-nstextfield/.
- (void)viewDidMoveToWindow:(NSWindow *)window
{
if ( window != nil )
{
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor redColor],
NSBackgroundColorAttributeName,
[NSColor yellowColor],
NSForegroundColorAttributeName,
nil];
// object-shadow text-field
NSTextView *fieldEditor = (NSTextView *)[window fieldEditor:YES
forObject:_shadowTextField];
[fieldEditor setSelectedTextAttributes:attributes];
// vignette text-field
fieldEditor = (NSTextView *)[window fieldEditor:YES
forObject:_vignetteTextField];
[fieldEditor setSelectedTextAttributes:attributes];
// opacity text-field
fieldEditor = (NSTextView *)[window fieldEditor:YES
forObject:_opacityTextField];
[fieldEditor setSelectedTextAttributes:attributes];
}
}
End result: In both cases I get the default white on cyan or whatever color you
call it. Anyone have a technique that works or some experience with this type
of modification?
-Michael
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]