--- old/src/macosx/native/sun/awt/CMenuItem.m 2013-07-26 04:45:50.000000000 +0400 +++ new/src/macosx/native/sun/awt/CMenuItem.m 2013-07-26 04:45:50.000000000 +0400 @@ -70,9 +70,15 @@ JNIEnv *env = [ThreadUtilities getJNIEnv]; JNF_COCOA_ENTER(env); - // If we are called as a result of user pressing a shorcut, do nothing, + // If we are called as a result of user pressing a shortcut, do nothing, // because AVTView has already sent corresponding key event to the Java - // layer from performKeyEquivalent + // layer from performKeyEquivalent. + // There is an exception from the rule above, though: if a window with + // a menu gets minimized by user and there are no other windows to take + // focus, the window's menu won't be removed from the global menu bar. + // However, the Java layer won't handle invocation by a shortcut coming + // from this "frameless" menu, because there are no active windows. This + // means we have to handle it here. NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent]; if ([currEvent type] == NSKeyDown) { NSString *menuKey = [sender keyEquivalent]; @@ -91,7 +97,8 @@ eventKey = [NSString stringWithCharacters: &newChar length: 1]; } - if ([menuKey isEqualToString:eventKey]) { + NSWindow *keyWindow = [NSApp keyWindow]; + if ([menuKey isEqualToString:eventKey] && keyWindow != nil) { return; } }