Hi Mike, sure, the value of oStrokeColorWell is different than the forecolor.
Let's say I have the string "ocean" within the NSTextView. Its forecolor is black, while the stroke color is red. I click between the "c" and the "e". The oForeColorWell properly displays the black color and the oStrokeColorWell properly displays the red color. Then I press the right arrow key and go between "e" and "a". Now both the colorWells display the black color. And more than what I see with my eyes, my log still displays the stoke color is rgba(1, 0, 0, 1); It seems that, since the oStrokeColorWell is active, it automatically gets its color value from the selected text. I would like to override the method from which it takes the color value, but I cannot guess which one it is. I unsuccessfully tried - (NSColor*)textColor; And I even tried to not to override the method below textViewDidChangeSelection. Same trouble. Any idea? Regards -- Leonardo > Da: Michael Babin <[email protected]> > Data: Sat, 01 Feb 2014 09:19:08 -0600 > A: Leonardo <[email protected]> > Oggetto: Re: How to display NSStrokeColorAttributeName on the NSColorPanel > > On Feb 1, 2014, at 3:37 AM, Leonardo <[email protected]> wrote: > >> When my 1st NSColorWell is active and I change the selection in my >> NSTextView, both NSColorWell and NSColorPanel display the foreColor of the >> selected tex. That's fine. >> >> Now I have a second NSColorWell that should display the strokeColor (or any >> other color) of the selected text. But I can't yet succeed. I my NSTextView >> subclass I have coded, unsuccessfully: >> >> - (void)textViewDidChangeSelection:(NSNotification*)aNotification >> { >> NSRange selRange = [self selectedRange], effRange; >> NSDictionary *attributes = [self.textStorage >> attributesAtIndex:selRange.location effectiveRange:&effRange]; >> if(attributes){ >> NSColor *strokeColor = [attributes >> objectForKey:NSStrokeColorAttributeName]; >> if(strokeColor){ >> [oStrokeColorWell setColor:strokeColor]; >> } >> } >> } >> >> Even if the strokeColor exists and gets set to the oStrokeColorWell, the >> oStrokeColorWell still displays the foreColor. Any idea? > > What's the value of oStrokeColorWell when you're setting it? That is, check to > make sure it isn't nil (outlet is connected). > > What's the value of strokeColor? Are you sure it is different than the > foreColor? > > - Mike _______________________________________________ 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]
