Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>NSTextFieldCell</code> inherits from <code>NSCell</code> (well, technically from <code>NSActionCell</code> which inherits from <code>NSCell</code>). The <code>NSCell</code> class is used to (from the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html" rel="noreferrer">docs</a>):</p> <blockquote> <p>The NSCell class <strong>provides a mechanism for displaying text or images in an NSView object without the overhead of a full NSView subclass</strong>.</p> </blockquote> <p>Notably, The cell class is used for <em>"displaying text or images"</em>, and not dealing with interaction with the user. Similarly, with the <code>NSTextField</code> class: </p> <blockquote> <p>The NSTextField class uses the NSTextFieldCell class to implement its user interface.</p> </blockquote> <p>The <code>NSTextField</code> deals with the actual user input, whilst using the text field cell to simply implement its user interface, and similarly, the delegate methods to provide notification when the editing of text has ended is provided through the <code>NSTextField</code> class and <em>not</em> through the <code>NSTextFieldCell</code> class.</p> <p>If you want to be notified of when editing ends in an <code>NSTableView</code>, then you need to register yourself as an observer of the <code>NSTextDidEndEditingNotification</code> (you might want to read the <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/Reference/Reference.html" rel="noreferrer">NSNotificationCenter</a> class reference if you are unfamiliar with notifications). To do this, place the following in your controller class; the <code>awakeFromNib</code> function is a good place to include it to ensure that it is called upon your application's startup:</p> <pre><code>NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(textDidEndEditing:) name:NSTextDidEndEditingNotification object:tableView]; </code></pre> <p>Where <code>tableView</code> is the pointer to your <code>NSTableView</code> object. Then, simply implement the method as follows:</p> <pre><code>- (void)textDidEndEditing:(NSNotification *)aNotification { // Do what you want here } </code></pre> <p>Don't forget to remove yourself as an observer upon deallocation:</p> <pre><code>- (void)dealloc { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc removeObserver:self]; } </code></pre> <p>The reason that you set the object that you are observing to be the <code>NSTableView</code> instance (and not the cell itself) is that under the hood, when you edit a cell in the table, the cell that you are dealing with isn't being edited directly; it is the window's (or a custom) field editor. When editing ends, the field editor then passes the new value for that cell on to the table view. However the table view will post a notification to say that a cell has finished being edited.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload