getting selected textColor
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.