Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

ADC Home > Reference Library > Technical Q&As > Cocoa > User Experience >

Preventing crashes when using multiple disabled but editable NSComboBoxes


Q: In Mac OS X 10.1.x, my Cocoa app crashes if I have more than one disabled but editable NSComboBox in a view and I click on one of them. How can I prevent this?

A: This is a bug that should be fixed in the next major release of Mac OS X. The workaround is fairly straightforward - use a subclass of NSComboBox that overrides -acceptsFirstResponder like Listing 1 demonstrates.



 @implementation MyComboBox
- (BOOL) acceptsFirstResponder {
       if ([self isEnabled] || NSAppKitVersionNumber>=636)
       return [super acceptsFirstResponder];
       else
    return NO;
}
@end

Listing 1. fixing the NSComboBox bug




[Jun 03 2002]




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.