title: How do I prevent an NSButton from registering presses while disabled?
body: <p><strong>Newbie Warning</strong></p>
  
  <p>I have a simple but vexing problem trying to disable an NSButton. Here is sample code to illustrate the problem:</p>
  
  <pre><code>- (IBAction)taskTriggeredByNSButtonPress:(id)sender {
  [ibOutletToNSButton setEnabled:NO];
  //A task is performed here that takes some time, during which time
  //the button should not respond to presses.
  //Once the task is completed, the button should become responsive again.
  [ibOutletToNSButton setEnabled:YES];
  }
  </code></pre>
  
  <p>This is what I observe. I press the button. The button becomes disabled (judging by its faded appearance), and the task begins executing. While the button is disabled and the task is executing, I press the button a second time. Nothing happens immediately, but once the task is completed, the <code>taskTriggeredByNSButtonPress:</code> method is called a second time, suggesting that the second button press was placed on hold and then activated once the button became re-enabled.</p>
  
  <p>I've tried all kinds of hacks to prevent the second button press from being recognized, including introducing a time delay after the <code>[ibOutletToNSButton setEnabled:NO];</code> statement, making the button hidden rather than disabled, covering the button with a custom view during the time it should be disabled, binding the button's <code>enabled</code> status to a property, and other things I'm too embarrassed to mention.</p>
  
  <p>Please help me understand why I can't get this simple task of disabling the button to work.</p>