title: How to detect when NSTextField has the focus or is it's content selected cocoa
body: <p>I have a NSTextField inside of a NSTableCellView, and I want an event which informs me when my NSTextField has got the focus for disabling several buttons, I found this method:</p>
  
  <pre><code>-(void)controlTextDidBeginEditing:(NSNotification *)obj{
      NSTextField *textField  = (NSTextField *)[obj object];
  
      if (textField != _nombreDelPaqueteTextField) {
          [_nuevaCuentaActivoButton   setEnabled:FALSE];
          [_nuevaCuentaPasivoButton   setEnabled:FALSE];
          [_nuevaCuentaIngresosButton setEnabled:FALSE];
          [_nuevaCuentaEgresosButton  setEnabled:FALSE];
      }
  }
  </code></pre>
  
  <p>but it triggers just when my textfield is begin editing as this says, I want the buttons disabled when I get the focus on the textField, not when I already started to type</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> Gonna put my code based on the help received by Joshua Nozzi, it still doesn't work</p>
  
  <p>MyNSTextField.h</p>
  
  <pre><code>#import &lt;Cocoa/Cocoa.h&gt;
  @class MyNSTextField;
  
  @protocol MyNSTextFieldDelegate
  
  @optional -(BOOL)textFieldDidResignFirstResponder:(NSTextField *)sender;
  @optional -(BOOL)textFieldDidBecomeFirstResponder:(NSTextField *)sender;
  
  @end
  
  @interface MyNSTextField : NSTextField
  
  @property (strong, nonatomic)           id &lt;MyNSTextFieldDelegate&gt; cellView;
  
  @end
  </code></pre>
  
  <p>MyNSTextField.m</p>
  
  <pre><code>#import "MyNSTextField.h"
  
  @implementation MyNSTextField
  
  - (BOOL)becomeFirstResponder
  {
      BOOL status = [super becomeFirstResponder];
      if (status)
  
          [self.cellView textFieldDidBecomeFirstResponder:self];
      return status;
  }
  
  - (BOOL)resignFirstResponder
  {
      BOOL status = [super resignFirstResponder];
      if (status)
          [self.cellView textFieldDidResignFirstResponder:self];
      return status;
  }
  
  @end
  </code></pre>
  
  <p>on my viewcontroller EdicionDeCuentasWC.m</p>
  
  <pre><code>#import "MyNSTextField.h"
  
  
  @interface EdicionDeCuentasWC ()&lt;NSTableViewDataSource, NSTableViewDelegate, NSControlTextEditingDelegate, NSPopoverDelegate, MyNSTextFieldDelegate&gt;
  @end
  
  
  @implementation EdicionDeCuentasWC
  #pragma mark MyNSTextFieldDelegate
  -(BOOL)textFieldDidBecomeFirstResponder:(NSTextField *)sender{
      NSLog(@"textFieldDidBecomeFirstResponder");
      return TRUE;
  }
  
  -(BOOL)textFieldDidResignFirstResponder:(NSTextField *)sender{
      NSLog(@"textFieldDidResignFirstResponder");
      return TRUE;
  }
  #pragma mark --
  @end
  </code></pre>
  
  <p>it's important to say in visual editor, already changed all my NSTextFields to MyNSTextField class and set delegate to my File's Owner (EdicionDeCuentasWC)</p>