I have a NSTextField
that uses no border and window background color while it is displayed but I want it to change to have the default border and white BG color when being edited. I know I can change these properties with:
nameTextField.bezeled = true
nameTextField.backgroundColor = NSColor.textBackgroundColor()
What I don't know is how to be notified when the textfield is started to be edited and when it's ended. There seem to be no actions for this. Is there any other way how could this behaviour be achieved?
EDIT: Actually, edit end can be detected via the textfield's change action when setting Action to "Send on End Editing" so that's solved but still how do I detect start editing?
You can set the
delegate
ofNSTextField
:then you can set a different state:
EDIT:
I think you can subclass
NSTextField
and override thebecomeFirstResponder
and theresignFirstResponder
, then you know theNSTextField
has the focus or not.