• 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: Displaying "helper text" in empty text fields
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying "helper text" in empty text fields


  • Subject: Re: Displaying "helper text" in empty text fields
  • From: Brian Webster <email@hidden>
  • Date: Fri, 19 Jul 2002 19:04:42 -0500

Try subclassing NSTextField and overriding becomeFirstResponder. I think this method will still be called before the field editor gets set up and inserted. You should be able to clear the text there and then call [super becomeFirstResponder] to have it start editing as per normal.

On Friday, July 19, 2002, at 05:34 PM, Charles Jolley wrote:

Hi Brian:

Thanks for the suggestion. I actually tried this already. This problem with this approach is that the controlTextDidBeginEditing notification does not get sent until the user actually changes the contents of the field. Thus, when the user clicks the field, the user finds himself editing the help text instead of an empty field. Is there some notification that gets delivered when the text field becomes first responder (well, when it get the field editor object and makes that first responder?)

Thanks,
-C

On Friday, July 19, 2002, at 02:29 PM, Brian Webster wrote:

On Friday, July 19, 2002, at 01:47 PM, cocoa-dev-
email@hidden wrote:

Basically if the actual contents of the field is empty, I want to
display a helper string in gray text until the user clicks. Then it
should be cleared.

Any ideas?

You can do a setStringValue: followed by a setTextColor: on the NSTextField to display colored text. To clear the field out when the user clicks in it, implement the method controlTextDidBeginEditing: in your text field's delegate object. You can then set the string value to @"" so that the text field is clear when it begins an editing session.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Re: Displaying "helper text" in empty text fields (From: Charles Jolley <email@hidden>)

  • Prev by Date: Images & Alternate Color Rows In Table
  • Next by Date: [OT (?)] Why don't iTunes & Disk Copy work with the same burning devices?
  • Previous by thread: Re: Displaying "helper text" in empty text fields
  • Next by thread: Re: cocoa-dev digest, Vol 2 #969 - 8 msgs
  • Index(es):
    • Date
    • Thread