src/macosx/native/sun/awt/CMenuItem.m

Print this page

        

*** 68,109 **** - (void)handleAction:(NSMenuItem *)sender { AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnv]; JNF_COCOA_ENTER(env); - // 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. - // 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]; - NSString *eventKey = [currEvent charactersIgnoringModifiers]; - - // Apple uses characters from private Unicode range for some of the - // keys, so we need to do the same translation here that we do - // for the regular key down events - if ([eventKey length] == 1) { - unichar origChar = [eventKey characterAtIndex:0]; - unichar newChar = NsCharToJavaChar(origChar, 0); - if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) { - newChar = origChar; - } - - eventKey = [NSString stringWithCharacters: &newChar length: 1]; - } - - NSWindow *keyWindow = [NSApp keyWindow]; - if ([menuKey isEqualToString:eventKey] && keyWindow != nil) { - return; - } - } if (fIsCheckbox) { static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem"); static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V"); --- 68,78 ----