Pregunta

How can I know when an NSTextField becomes the first responder (i.e. when the user click on it to activate it, but before they start typing). I tried controlTextDidBeginEditing but this doesn't get called until the user types the first character.

¿Fue útil?

Solución

Subclass the NSTextField and overwrite the

- (BOOL)becomeFirstResponder

method, defined in the NSResponder class (a superclass of NSTextField), like so:

- (BOOL)becomeFirstResponder {

  BOOL flag=[super becomeFirstResponder];

  if(flag)
  {
    // text field will become first responder
  }

  return flag
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top