Re: Displaying "helper text" in empty text fields
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.