• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to display NSStrokeColorAttributeName on the NSColorPanel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to display NSStrokeColorAttributeName on the NSColorPanel


  • Subject: Re: How to display NSStrokeColorAttributeName on the NSColorPanel
  • From: Leonardo <email@hidden>
  • Date: Sat, 01 Feb 2014 17:12:36 +0100
  • Thread-topic: How to display NSStrokeColorAttributeName on the NSColorPanel

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@hidden>
> Data: Sat, 01 Feb 2014 09:19:08 -0600
> A: Leonardo <email@hidden>
> Oggetto: Re: How to display NSStrokeColorAttributeName on the NSColorPanel
>
> On Feb 1, 2014, at 3:37 AM, Leonardo <email@hidden> 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@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


  • Prev by Date: Re: Legal Opinion on GCUndoManager
  • Next by Date: NSArrayController - Remove and immediately deallocate objects
  • Previous by thread: How to display NSStrokeColorAttributeName on the NSColorPanel
  • Next by thread: Re: How to display NSStrokeColorAttributeName on the NSColorPanel
  • Index(es):
    • Date
    • Thread