becomeFirstResponder and resignFirstResponder

  • I have subclassed NSTextField and overridden becomeFirstResponder and
    resignFirstResponder methods. Everytime I click in my custom NSTextField,
    both the methods get called, instead of just becomeFirstResponder. Is there
    a reason for this?

    I want to show a border around the NSTextField while the user is in there,
    and remove the border when the user has left the NSTextField, but can't seem
    to because both methods get called at the same time.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • I have subclassed NSTextField and overridden becomeFirstResponder and
    resignFirstResponder methods. Everytime I click in my custom NSTextField,
    both the methods get called, instead of just becomeFirstResponder. Is there
    a reason for this?

    I want to show a border around the NSTextField while the user is in there,
    and remove the border when the user has left the NSTextField, but can't seem
    to because both methods get called at the same time.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • The reason they both happen immediately is that an NSTextField actually
    uses and NSTextView for editing.  So, as soon as it is made first
    responder, it starts editing and hands over first responder status to
    the NSTextView editor.  While a control is editing, the -currentEditor
    method will return a non-nil value.  You might be able to catch when
    editing starts by overriding NSTextFieldCell's -editWithFrame:... and
    selectWithFrame:... methods.  And you can probably find out when it
    ends by overriding NSTextField's -textDidEndEditing:.

    Mike

    Begin forwarded message:

    > From: "Shoaib" <shoaib...>
    > Date: Sun Dec 29, 2002  8:27:54 AM US/Pacific
    > To: "<cocoa-dev...>" <cocoa-dev...>,
    > "<cocoa-dev...>" <cocoa-dev...>
    > Subject: becomeFirstResponder and resignFirstResponder
    >
    > I have subclassed NSTextField and overridden becomeFirstResponder and
    > resignFirstResponder methods. Everytime I click in my custom
    > NSTextField, both the methods get called, instead of just
    > becomeFirstResponder. Is there a reason for this?
    >
    > I want to show a border around the NSTextField while the user is in
    > there, and remove the border when the user has left the NSTextField,
    > but can't seem to because both methods get called at the same time.
    > _______________________________________________
    > cocoa-dev mailing list | <cocoa-dev...>
    > 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 | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month december 2002 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today