• 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
getting selected textColor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

getting selected textColor


  • Subject: getting selected textColor
  • From: Ruben Smits <email@hidden>
  • Date: Mon, 15 Mar 2004 11:13:04 +0100

Hi,

I want the NSColorPanel to display the color of the currently selected
text in my application. I know this is not really default behavior for
OSX, by default the last selected color in the panel is displayed.

When multiple colors are used in a selected range, I want to display
the color of the first textRun.

So I ask for the [NSColor selectedTextColor]. In an NSLog() this always
results in "NSNamedColorSpace System selectedTextColor", independent of
the color I choose in the colorPanel. Therefore I also tried
NSColor *selectedTextColor = [[[myTextView
selectedTextAttributes]objectForKey:@"NSColor"]; This has the same
result.

Then I use [[NSColorPanel sharedColorPanel]setColor:selectedTextColor];
to set the color in the colorPanel. Unfortunately, this always results
in a black color in the colorPanel. (Black is default textColor.) This
call also sets the color to the selected text. Problem: When I have
multiple colors in my selection, all will become 1 color.

My questions:
- Can I use [NSColor selectedTextColor] to set the correct color in the
colorPanel?
- How do I prevent that color in my text is set with a call of
[NSColorPanel setColor]

Thanks!

----------------------
Ruben Smits
----------------------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: getting selected textColor
      • From: Satoshi Matsumoto <email@hidden>
  • Prev by Date: Re: lost with help books
  • Next by Date: Creating NSImage with NSData
  • Previous by thread: Re: NSArrayController Howto use in simple non-document application?
  • Next by thread: Re: getting selected textColor
  • Index(es):
    • Date
    • Thread