When editing in a NSTextField and return is pressed, it fires the text field's
action and also sends performKeyEquivalent: to the window, which clicks the
default button. Usually that's just fine, but in the case where a view-based
table view has editable NSTextFields in it, this makes no sense.
Anybody figured out how to prevent this?
---
It happens in NSTextField textDidEndEditing, so there's no stopping
performKeyEquivalent: from being called short of subclassing NSTextField and
reimplementing that method. (Eww)
You also can't disable the key equivalent on the button in
controlTextDidBeginEditing and re-enable it in controlTextDidEndEditing,
because the performKeyEquivalent: is called after the controlTextDidEndEditing
notification is sent.
I thought maybe I could so some light NSTExtField subclassing and use
NSWindow's disableKeyEquivalentForDefaultButtonCell...
@implementation MyTableCellTextField
- (void)textDidBeginEditing:(NSNotification *)notification;
{
[self.window disableKeyEquivalentForDefaultButtonCell];
[super textDidBeginEditing:notification];
}
- (void)textDidEndEditing:(NSNotification *)notification;
{
[super textDidEndEditing:notification];
[self.window enableKeyEquivalentForDefaultButtonCell];
}
@end
Sadly, that doesn't work. My default button is still clicked when [super
textDidEndEditing:] calls performKeyEquivalent:, despite the defaultButtonCell
being the right button… As a matter of fact, looking at the implementation of
those NSWindow methods shows they're identical to each other… which makes
absolutely no sense. So obviously that doesn't do what one would expect.
This is leaving me little choice but to do something very specialized and ugly.
Am I missing something?
--
Seth Willits
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]