• 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
NSTextField: Change Text Color at Insertion Point?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextField: Change Text Color at Insertion Point?


  • Subject: NSTextField: Change Text Color at Insertion Point?
  • From: Alexander Heinz <email@hidden>
  • Date: Mon, 8 Feb 2010 11:22:05 -0500

Hello Cocoa-devs,

I've a got an out-of-the box NSTextField that I'm trying to apply various string attributes to, including colors. I'm not using the standard color panel, since the application I'm writing can only support a very limited set of colors, so I just have a menu with a list of colors. So far, the user can select text in the field, click (or press a keyboard shortcut for) one of the menu items, and the selected text will change colors (via NSText's - setTextColor: range: method.) If the field is empty, the user can also choose one of the menu items and any text he or she types will appear in the selected color.

My question is this: let's say my user has already typed some text in black (or whatever color) and now wants to change the "active color" of the text at the insertion point, such that any text he or she types appears in the new color. I've tried calling - setTextColor: range: with range: being the end of the string, but this appears to do nothing.

I'm sure this should be possible, because the standard NSColorPanel allows you to do this (as long as the field is set to use rich text, which mine is.) Google shows me a couple ways to change the color of the insertion point itself, but not the color of the text at the insertion point.

Anyone know how to do this?

Thanks in advance,
- Alex_______________________________________________

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

  • Follow-Ups:
    • Re: NSTextField: Change Text Color at Insertion Point?
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: Re: always show warnings?
  • Next by Date: Re: NSTextField: Change Text Color at Insertion Point?
  • Previous by thread: Re: Create a Quicktime-like window
  • Next by thread: Re: NSTextField: Change Text Color at Insertion Point?
  • Index(es):
    • Date
    • Thread