On Thu, Jun 12, 2008 at 11:14 AM, Mattias Arrelid <[EMAIL PROTECTED]> wrote: > On Wed, Jun 11, 2008 at 6:15 PM, Mattias Arrelid <[EMAIL PROTECTED]> wrote: >> Hi Douglas, >> >> On Wed, Jun 11, 2008 at 5:30 PM, Douglas Davidson <[EMAIL PROTECTED]> wrote: >>> >>> On Jun 11, 2008, at 3:24 AM, Mattias Arrelid wrote: >>> >>>> Haven't anyone stumbled upon something similar, or a solution to this? >>> >>> I believe it was answered. You don't want to use setMarkedTextAttributes:, >>> because marked text is the uncommitted text you see while using an input >>> method. You can use setSelectedTextAttributes: instead. >> >> It seems that I forgot to mention that I've tried that without >> success. I can successfully set the background color of the selection >> using this (in the initWithFrame: method of my custom text view): >> >> NSMutableDictionary *dict = [[[self selectedTextAttributes] >> mutableCopy] autorelease]; >> [dict setObject:[NSColor redColor] forKey:NSBackgroundColorAttributeName]; >> [self setSelectedTextAttributes:dict]; >> >> Now, any selected text will have a red background selection. Changing >> the NSBackgroundColorAttributeName attribute to >> NSForegroundColorAttributeName makes the selection background color >> the system's default again, but doesn't affect the color of the >> selected text. >> >> Am I missing something here? > > Just to test things; I did setup a simple test project, and in there > it works just fine setting the foreground color. Back to the debugger > to see where that call to setSelectedTextAttributes: is going.
Sorry for my many replies... It turns out that if you set the NSForegroundColorAttributeName of the attributed string in NSTextView's text storage, the call to setSelectedTextAttributes: doesn't have any effect when called as described below: NSMutableDictionary *dict = [[[textView selectedTextAttributes] mutableCopy] autorelease]; [dict setObject:[NSColor redColor] forKey:NSForegroundColorAttributeName]; [textView setSelectedTextAttributes:dict]; Setting the background color works fine though. I cannot see anything regarding this limitation in the documentation - is it by design or is it a bug? Best regards Mattias _______________________________________________ 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 [EMAIL PROTECTED]