NSTextField and first responder - when does a feature become a bug?
NSTextField and first responder - when does a feature become a bug?
- Subject: NSTextField and first responder - when does a feature become a bug?
- From: Jeremy Dronfield <email@hidden>
- Date: Fri, 4 Jun 2004 17:19:46 +0100
According to the archive, this is a FAQ, but doesn't seem to have ever
received a conclusive answer.
I'm trying to create a search field with placeholder-string to use in a
pre-Panther application by using an NSTextField subclass. I want to
change the text colour to black and select the text when the field
becomes active, and set it to a grey placeholder string when becoming
inactive. Fine. According to the NSTextField documentation, the way to
do this sort of setting up is to override -becomeFirstResponder and
-resignFirstResponder.
The problem, as others have noticed, is that when a text field receives
a -becomeFirstResponder, it then immediately receives
-resignFirstResponder as the field editor takes over that status.
According to the NSTextField documentation,
"Subclasses can override this method [-resignFirstResponder] to update
state or perform some action such as unhighlighting the selection"
Likewise,
"Subclasses can override this method [-becomeFirstResponder] to update
state or perform some action such as highlighting the selection"
If you were to follow this document's suggestion, your text field would
highlight its selection, then immediately unhighlight it (i.e. appear
to do nothing). So is this a doc bug or an API bug? I think it must be
an API bug, since otherwise -resignFirstResponder seems to have no
purpose, because it is only sent when a text field BECOMES first
responder. (It isn't sent when another control is selected.)
Regards,
-Jeremy
===================================
SkoobySoft, home of viJournal
email: email@hidden or visit:
http://freespace.virgin.net/jeremy.dronfield/skoobysoft.html
===================================
_______________________________________________
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.