From 90a45dca29f87fb4933d267bee2e31bc2360b442 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Sun, 1 Aug 2010 20:19:26 -0500 Subject: [PATCH] some fixes to default buttons to make them more cocoa compliant... --- AppKit/CPButton.j | 6 ++++++ AppKit/CPWindow/CPWindow.j | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index c2f212644..7cfe38e54 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -572,9 +572,15 @@ CPButtonStateMixed = CPThemeState("mixed"); // Check if the key equivalent is the enter key // Treat \r and \n as the same key equivalent. See issue #710. if (aString === CPNewlineCharacter || aString === CPCarriageReturnCharacter) + { [[self window] setDefaultButton:self]; + [self setDefaultButton:YES]; + } else if ([[self window] defaultButton] === self) + { [[self window] setDefaultButton:nil]; + [self setDefaultButton:NO]; + } _keyEquivalent = aString || @""; } diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index d010871ed..de0744e7f 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -2406,9 +2406,12 @@ CPTexturedBackgroundWindowMask if (_defaultButton === aButton) return; - [_defaultButton setDefaultButton:NO]; + if ([_defaultButton keyEquivalent] === CPCarriageReturnCharacter) + [_defaultButton setKeyEquivalent:nil]; + _defaultButton = aButton; - [_defaultButton setDefaultButton:YES]; + + [_defaultButton setKeyEquivalent:CPCarriageReturnCharacter]; } - (CPButton)defaultButton