title: Cocoa: Delaying one method call until a subsequent call is processed
body: <p>I've found myself in the following situation: I've got an <code>NSTableView</code> subclass with an active cell. when I click elsewhere on the user interface, the delegate method (i) is fired, this in turn fires (ii) (my own method) cocoa then proceeds to process the click, resulting in the final two calls. I was surprised and disappointed by this sequence, since I had assumed the mouse click would be the first rather than the last event processed. It also causes me a problem because the ideal implementation of <code>manageState</code> is dependent on some of the processing I do in <code>mouseDown:</code>, but of course when <code>manageState</code> is called <code>mouseDown:</code> has not yet been executed. </p>
  
  <p>Is their a way to delay the execution of <code>manageState</code> until <code>mouseDown</code> has returned? For example, in <code>manageState</code> I'd say something like <em>Stop! a mouse down event might be in the events queue. Wait until it's finished, then resume</em>. As the previous sentence implies, it's also possible that this method could be triggered by something other than a mouse down. In this situation, there's no need to look out for a mouse down event and processing can continue as normal.  </p>
  
  <pre><code>MOUSE CLICK on NSTextView while NSTableView cell has focus...
  
  +-------------------------+--------------------------------------------------------+
  |Event                    |Triggered because                                       |
  +=========================+========================================================+
  |controlTextDidEndEditing:|The mouse click ends the editing session                |
  |                         |of the active cell in my table view                     |
  +-------------------------+--------------------------------------------------------+
  |manageState              |This method is a selector that belongs to a notification|
  |                         |that is fired from within controlTextDidEndEditing:     |
  +-------------------------+--------------------------------------------------------+
  |becomeFirstResponder     |I clicked on the NSTextView instance                    |
  +-------------------------+--------------------------------------------------------+
  |mouseDown:               |Finally, the click that started it all is processed     |
  +-------------------------+--------------------------------------------------------+
  </code></pre>