Some keys like arrow keys send double command events to NSView's performKeyEquivalent:, one for key up and one for key down. This doesn't make sense for us, so only handle key down command events. b=363005 r=cbarrett r=froodian r=cl

This commit is contained in:
joshmoz%gmail.com 2006-12-11 05:31:33 +00:00
parent 6e56193b6e
commit d90417e60a

View File

@ -3627,12 +3627,17 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
- (BOOL)performKeyEquivalent:(NSEvent*)theEvent
{
if (mInComposition)
// Don't bother if we're in composition. Also do not handle anything
// that isn't a key down event. Some keys like arrow keys send command
// events for up and down, and we only care about down. See bug 363002.
if (mInComposition || ([theEvent type] != NSKeyDown))
return NO;
// see if the menu system will handle the event
if ([[NSApp mainMenu] performKeyEquivalent:theEvent])
return YES;
// handle the event ourselves
nsKeyEvent geckoEvent(PR_TRUE, 0, nsnull);
geckoEvent.refPoint.x = geckoEvent.refPoint.y = 0;
[self convertKeyEvent:theEvent message:NS_KEY_PRESS toGeckoEvent:&geckoEvent];