< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m

Print this page




  99             // is not U.S. (Devanagari in this case)
 100             // With current implementation, EventKey = MenuKey = e irrespective of
 101             // input method
 102             NSString *eventKey = [sender keyEquivalent];
 103             // Apple uses characters from private Unicode range for some of the
 104             // keys, so we need to do the same translation here that we do
 105             // for the regular key down events
 106             if ([eventKey length] == 1) {
 107                 unichar origChar = [eventKey characterAtIndex:0];
 108                 unichar newChar =  NsCharToJavaChar(origChar, 0);
 109                 if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
 110                     newChar = origChar;
 111                 }
 112                 eventKey = [NSString stringWithCharacters: &newChar length: 1];
 113             }
 114             NSWindow *keyWindow = [NSApp keyWindow];
 115             if (keyWindow != nil) {
 116                 return;
 117             }
 118         }
 119         else {
 120             static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
 121             static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
 122             
 123             NSUInteger modifiers = [currEvent modifierFlags];
 124             jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
 125             
 126             JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
 127         }
 128     }
 129     JNF_COCOA_EXIT(env);
 130     
 131 }
 132 
 133 - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
 134     
 135     NSUInteger modifierMask = 0;
 136     
 137     if (![theKeyEquivalent isEqualToString:@""]) {
 138         // Force the key equivalent to lower case if not using the shift key.
 139         // Otherwise AppKit will draw a Shift glyph in the menu.
 140         if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) == 0) {
 141             theKeyEquivalent = [theKeyEquivalent lowercaseString];
 142         }
 143         
 144         // Hack for the question mark -- SHIFT and / means use the question mark.
 145         if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) != 0 &&
 146             [theKeyEquivalent isEqualToString:@"/"])
 147         {
 148             theKeyEquivalent = @"?";




  99             // is not U.S. (Devanagari in this case)
 100             // With current implementation, EventKey = MenuKey = e irrespective of
 101             // input method
 102             NSString *eventKey = [sender keyEquivalent];
 103             // Apple uses characters from private Unicode range for some of the
 104             // keys, so we need to do the same translation here that we do
 105             // for the regular key down events
 106             if ([eventKey length] == 1) {
 107                 unichar origChar = [eventKey characterAtIndex:0];
 108                 unichar newChar =  NsCharToJavaChar(origChar, 0);
 109                 if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
 110                     newChar = origChar;
 111                 }
 112                 eventKey = [NSString stringWithCharacters: &newChar length: 1];
 113             }
 114             NSWindow *keyWindow = [NSApp keyWindow];
 115             if (keyWindow != nil) {
 116                 return;
 117             }
 118                 }
 119                 
 120         static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
 121         static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
 122 
 123         NSUInteger modifiers = [currEvent modifierFlags];
 124         jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
 125 
 126         JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
 127     }

 128     JNF_COCOA_EXIT(env);
 129         
 130 }
 131 
 132 - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
 133     
 134     NSUInteger modifierMask = 0;
 135     
 136     if (![theKeyEquivalent isEqualToString:@""]) {
 137         // Force the key equivalent to lower case if not using the shift key.
 138         // Otherwise AppKit will draw a Shift glyph in the menu.
 139         if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) == 0) {
 140             theKeyEquivalent = [theKeyEquivalent lowercaseString];
 141         }
 142         
 143         // Hack for the question mark -- SHIFT and / means use the question mark.
 144         if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) != 0 &&
 145             [theKeyEquivalent isEqualToString:@"/"])
 146         {
 147             theKeyEquivalent = @"?";


< prev index next >