jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m
author aniyogi
Wed, 01 Jun 2016 11:16:22 +0530
changeset 39018 df734f00b30a
parent 38384 05e90f2c9ab8
child 42735 d9e129a783ab
permissions -rw-r--r--
8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar Reviewed-by: serb, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
23624
863a7441b898 8036757: [macosx] Space menu accelerator not rendered correctly
pchelko
parents: 19365
diff changeset
     2
 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
#import <JavaNativeFoundation/JavaNativeFoundation.h>
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
    27
#include <Carbon/Carbon.h>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    28
#import "CMenuItem.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
#import "CMenu.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
#import "AWTEvent.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
#import "ThreadUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
#import "java_awt_Event.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
#import "java_awt_event_KeyEvent.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    35
#import "sun_lwawt_macosx_CMenuItem.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    36
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
#define NOT_A_CHECKBOXMENU -2
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    38
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
@implementation CMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    42
- (id) initWithPeer:(jobject)peer asSeparator: (NSNumber *) asSeparator{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
    43
    AWT_ASSERT_APPKIT_THREAD;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
    self = [super initWithPeer:peer];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
    if (self) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
        if ([asSeparator boolValue]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
            fMenuItem = (NSMenuItem*)[NSMenuItem separatorItem];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
            [fMenuItem retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    49
        } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    50
            fMenuItem = [[NSMenuItem alloc] init];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    51
            [fMenuItem setAction:@selector(handleAction:)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
            [fMenuItem setTarget:self];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
        fIsCheckbox = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
        fIsEnabled = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    56
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    57
    return self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    58
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    59
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    60
// This is because NSApplication doesn't check the target's window when sending
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    61
// actions; they only check the target itself.  We always return YES,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    62
// since we shouldn't even be installed unless our window is active.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    63
- (BOOL) worksWhenModal {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    64
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    65
}
39018
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
    66
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
// Events
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
- (void)handleAction:(NSMenuItem *)sender {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
    69
    AWT_ASSERT_APPKIT_THREAD;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
    JNIEnv *env = [ThreadUtilities getJNIEnv];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
    71
    JNF_COCOA_ENTER(env);
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
    72
    
19022
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    73
    // If we are called as a result of user pressing a shortcut, do nothing,
17144
0c7842966236 8008366: [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
leonidr
parents: 15985
diff changeset
    74
    // because AVTView has already sent corresponding key event to the Java
19022
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    75
    // layer from performKeyEquivalent.
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    76
    // There is an exception from the rule above, though: if a window with
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    77
    // a menu gets minimized by user and there are no other windows to take
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    78
    // focus, the window's menu won't be removed from the global menu bar.
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    79
    // However, the Java layer won't handle invocation by a shortcut coming
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    80
    // from this "frameless" menu, because there are no active windows. This
4d36c6935abb 8007267: [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
leonidr
parents: 18756
diff changeset
    81
    // means we have to handle it here.
13781
bf3d53b1fba7 7160951: ActionListener called twice for JMenuItem using ScreenMenuBar
leonidr
parents: 12283
diff changeset
    82
    NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    83
    if (fIsCheckbox) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
        static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    85
        static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
    86
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    87
        // Send the opposite of what's currently checked -- the action
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
        // indicates what state we're going to.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    89
        NSInteger state = [sender state];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    90
        jboolean newState = (state == NSOnState ? JNI_FALSE : JNI_TRUE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    91
        JNFCallVoidMethod(env, fPeer, jm_ckHandleAction, newState);
38384
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    92
    }
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    93
    else {
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    94
        if ([currEvent type] == NSKeyDown) {
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    95
            // Event available through sender variable hence NSApplication
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    96
            // not needed for checking the keyboard input sans the modifier keys
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    97
            // Also, the method used to fetch eventKey earlier would be locale dependent
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    98
            // With earlier implementation, if MenuKey: e EventKey: ा ; if input method
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
    99
            // is not U.S. (Devanagari in this case)
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   100
            // With current implementation, EventKey = MenuKey = e irrespective of
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   101
            // input method
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   102
            NSString *eventKey = [sender keyEquivalent];
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   103
            // Apple uses characters from private Unicode range for some of the
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   104
            // keys, so we need to do the same translation here that we do
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   105
            // for the regular key down events
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   106
            if ([eventKey length] == 1) {
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   107
                unichar origChar = [eventKey characterAtIndex:0];
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   108
                unichar newChar =  NsCharToJavaChar(origChar, 0);
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   109
                if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) {
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   110
                    newChar = origChar;
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   111
                }
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   112
                eventKey = [NSString stringWithCharacters: &newChar length: 1];
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   113
            }
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   114
            NSWindow *keyWindow = [NSApp keyWindow];
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   115
            if (keyWindow != nil) {
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   116
                return;
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   117
            }
39018
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   118
        }
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   119
        else {
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   120
            static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   121
            static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   122
            
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   123
            NSUInteger modifiers = [currEvent modifierFlags];
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   124
            jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   125
            
df734f00b30a 8158230: [macosx] ActionEvent is not fired for menu item with option apple.laf.useScreenMenuBar
aniyogi
parents: 38384
diff changeset
   126
            JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
38384
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   127
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   128
    }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   129
    JNF_COCOA_EXIT(env);
38384
05e90f2c9ab8 8152492: [macosx swing] double key event actions when using Mac menubar
aniyogi
parents: 34809
diff changeset
   130
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   131
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   132
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   133
- (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   134
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   135
    NSUInteger modifierMask = 0;
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   136
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   137
    if (![theKeyEquivalent isEqualToString:@""]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   138
        // Force the key equivalent to lower case if not using the shift key.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   139
        // Otherwise AppKit will draw a Shift glyph in the menu.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   140
        if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) == 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   141
            theKeyEquivalent = [theKeyEquivalent lowercaseString];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   142
        }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   143
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   144
        // Hack for the question mark -- SHIFT and / means use the question mark.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   145
        if ((modifiers & java_awt_event_KeyEvent_SHIFT_MASK) != 0 &&
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   146
            [theKeyEquivalent isEqualToString:@"/"])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   147
        {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   148
            theKeyEquivalent = @"?";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   149
            modifiers &= ~java_awt_event_KeyEvent_SHIFT_MASK;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   150
        }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   151
        
13781
bf3d53b1fba7 7160951: ActionListener called twice for JMenuItem using ScreenMenuBar
leonidr
parents: 12283
diff changeset
   152
        modifierMask = JavaModifiersToNsKeyModifiers(modifiers, NO);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   153
    }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   154
    
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 14312
diff changeset
   155
    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
12283
253d9a09f674 7124551: [macosx] Once added, Menu shortcut cannot be removed
serb
parents: 12047
diff changeset
   156
        [fMenuItem setKeyEquivalent:theKeyEquivalent];
253d9a09f674 7124551: [macosx] Once added, Menu shortcut cannot be removed
serb
parents: 12047
diff changeset
   157
        [fMenuItem setKeyEquivalentModifierMask:modifierMask];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   158
        [fMenuItem setTitle:theLabel];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   159
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   160
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   161
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   162
- (void) setJavaImage:(NSImage *)theImage {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   163
    
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 14312
diff changeset
   164
    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   165
        [fMenuItem setImage:theImage];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   166
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   167
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   168
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   169
- (void) setJavaToolTipText:(NSString *)theText {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   170
    
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 14312
diff changeset
   171
    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   172
        [fMenuItem setToolTip:theText];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   173
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   174
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   175
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   176
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   177
- (void)setJavaEnabled:(BOOL) enabled {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   178
    
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 14312
diff changeset
   179
    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   180
        @synchronized(self) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   181
            fIsEnabled = enabled;
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   182
            
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   183
            // Warning:  This won't work if the parent menu is disabled.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   184
            // See [CMenu syncFromJava]. We still need to call it here so
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   185
            // the NSMenuItem itself gets properly updated.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   186
            [fMenuItem setEnabled:fIsEnabled];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   187
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   188
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   189
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   190
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   191
- (BOOL)isEnabled {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   192
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
    BOOL enabled = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
    @synchronized(self) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   195
        enabled = fIsEnabled;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   196
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
    return enabled;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   201
- (void)setJavaState:(BOOL)newState {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   202
    
15322
3638f33225ec 7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents: 14312
diff changeset
   203
    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   204
        [fMenuItem setState:(newState ? NSOnState : NSOffState)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   205
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   206
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   207
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   208
- (void)cleanup {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   209
    [fMenuItem setAction:NULL];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   210
    [fMenuItem setTarget:nil];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   211
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   212
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   213
- (void)dealloc {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   214
    [fMenuItem release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   215
    fMenuItem = nil;
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   216
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   217
    [super dealloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   218
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   219
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   220
- (void)addNSMenuItemToMenu:(NSMenu *)inMenu {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   221
    [inMenu addItem:fMenuItem];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   222
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   223
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   224
- (NSMenuItem *)menuItem {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   225
    return [[fMenuItem retain] autorelease];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   226
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   227
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   228
- (void)setIsCheckbox {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   229
    fIsCheckbox = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   230
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   231
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   232
- (void) _createMenuItem_OnAppKitThread: (NSMutableArray *)argValue {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   233
    jobject cPeerObjGlobal = (jobject)[[argValue objectAtIndex: 0] pointerValue];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   234
    NSNumber * asSeparator = (NSNumber *)[argValue objectAtIndex: 1];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   235
    CMenuItem *aCMenuItem = [self initWithPeer: cPeerObjGlobal asSeparator: asSeparator];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   236
    [argValue removeAllObjects];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   237
    [argValue addObject: aCMenuItem];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   238
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   239
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   240
- (NSString *)description {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   241
    return [NSString stringWithFormat:@"CMenuItem[ %@ ]", fMenuItem];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   242
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   243
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   244
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   245
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   246
/** Convert a Java keycode for SetMenuItemCmd */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   247
static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   248
    unichar macKey = 0;
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   249
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   250
    if ((awtKey >= java_awt_event_KeyEvent_VK_0 && awtKey <= java_awt_event_KeyEvent_VK_9) ||
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   251
        (awtKey >= java_awt_event_KeyEvent_VK_A && awtKey <= java_awt_event_KeyEvent_VK_Z))
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   252
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   253
        // These ranges are the same in ASCII
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   254
        macKey = awtKey;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   255
    } else if (awtKey >= java_awt_event_KeyEvent_VK_F1 && awtKey <= java_awt_event_KeyEvent_VK_F12) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   256
        // Support for F1 - F12 has been around since Java 1.0 and fall into a lower range.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   257
        macKey = awtKey - java_awt_event_KeyEvent_VK_F1 + NSF1FunctionKey;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   258
    } else if (awtKey >= java_awt_event_KeyEvent_VK_F13 && awtKey <= java_awt_event_KeyEvent_VK_F24) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   259
        // Support for F13-F24 came in Java 1.2 and are at a different range.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   260
        macKey = awtKey - java_awt_event_KeyEvent_VK_F13 + NSF13FunctionKey;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   261
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   262
        // Special characters
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   263
        switch (awtKey) {
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   264
            case java_awt_event_KeyEvent_VK_BACK_QUOTE      : macKey = '`'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   265
            case java_awt_event_KeyEvent_VK_QUOTE           : macKey = '\''; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   266
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   267
            case java_awt_event_KeyEvent_VK_ESCAPE          : macKey = 0x1B; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   268
            case java_awt_event_KeyEvent_VK_SPACE           : macKey = ' '; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   269
            case java_awt_event_KeyEvent_VK_PAGE_UP         : macKey = NSPageUpFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   270
            case java_awt_event_KeyEvent_VK_PAGE_DOWN       : macKey = NSPageDownFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   271
            case java_awt_event_KeyEvent_VK_END             : macKey = NSEndFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   272
            case java_awt_event_KeyEvent_VK_HOME            : macKey = NSHomeFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   273
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   274
            case java_awt_event_KeyEvent_VK_LEFT            : macKey = NSLeftArrowFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   275
            case java_awt_event_KeyEvent_VK_UP              : macKey = NSUpArrowFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   276
            case java_awt_event_KeyEvent_VK_RIGHT           : macKey = NSRightArrowFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   277
            case java_awt_event_KeyEvent_VK_DOWN            : macKey = NSDownArrowFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   278
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   279
            case java_awt_event_KeyEvent_VK_COMMA           : macKey = ','; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   280
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   281
                // Mac OS doesn't distinguish between the two '-' keys...
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   282
            case java_awt_event_KeyEvent_VK_MINUS           :
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   283
            case java_awt_event_KeyEvent_VK_SUBTRACT        : macKey = '-'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   284
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   285
                // or the two '.' keys...
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   286
            case java_awt_event_KeyEvent_VK_DECIMAL         :
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   287
            case java_awt_event_KeyEvent_VK_PERIOD          : macKey = '.'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   288
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   289
                // or the two '/' keys.
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   290
            case java_awt_event_KeyEvent_VK_DIVIDE          :
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   291
            case java_awt_event_KeyEvent_VK_SLASH           : macKey = '/'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   292
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   293
            case java_awt_event_KeyEvent_VK_SEMICOLON       : macKey = ';'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   294
            case java_awt_event_KeyEvent_VK_EQUALS          : macKey = '='; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   295
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   296
            case java_awt_event_KeyEvent_VK_OPEN_BRACKET    : macKey = '['; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   297
            case java_awt_event_KeyEvent_VK_BACK_SLASH      : macKey = '\\'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   298
            case java_awt_event_KeyEvent_VK_CLOSE_BRACKET   : macKey = ']'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   299
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   300
            case java_awt_event_KeyEvent_VK_MULTIPLY        : macKey = '*'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   301
            case java_awt_event_KeyEvent_VK_ADD             : macKey = '+'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   302
                
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   303
            case java_awt_event_KeyEvent_VK_HELP            : macKey = NSHelpFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   304
            case java_awt_event_KeyEvent_VK_TAB             : macKey = NSTabCharacter; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   305
            case java_awt_event_KeyEvent_VK_ENTER           : macKey = NSNewlineCharacter; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   306
            case java_awt_event_KeyEvent_VK_BACK_SPACE      : macKey = NSBackspaceCharacter; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   307
            case java_awt_event_KeyEvent_VK_DELETE          : macKey = NSDeleteCharacter; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   308
            case java_awt_event_KeyEvent_VK_CLEAR           : macKey = NSClearDisplayFunctionKey; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   309
            case java_awt_event_KeyEvent_VK_AMPERSAND       : macKey = '&'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   310
            case java_awt_event_KeyEvent_VK_ASTERISK        : macKey = '*'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   311
            case java_awt_event_KeyEvent_VK_QUOTEDBL        : macKey = '\"'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   312
            case java_awt_event_KeyEvent_VK_LESS            : macKey = '<'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   313
            case java_awt_event_KeyEvent_VK_GREATER         : macKey = '>'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   314
            case java_awt_event_KeyEvent_VK_BRACELEFT       : macKey = '{'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   315
            case java_awt_event_KeyEvent_VK_BRACERIGHT      : macKey = '}'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   316
            case java_awt_event_KeyEvent_VK_AT              : macKey = '@'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   317
            case java_awt_event_KeyEvent_VK_COLON           : macKey = ':'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   318
            case java_awt_event_KeyEvent_VK_CIRCUMFLEX      : macKey = '^'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   319
            case java_awt_event_KeyEvent_VK_DOLLAR          : macKey = '$'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   320
            case java_awt_event_KeyEvent_VK_EXCLAMATION_MARK : macKey = '!'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   321
            case java_awt_event_KeyEvent_VK_LEFT_PARENTHESIS : macKey = '('; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   322
            case java_awt_event_KeyEvent_VK_NUMBER_SIGN     : macKey = '#'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   323
            case java_awt_event_KeyEvent_VK_PLUS            : macKey = '+'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   324
            case java_awt_event_KeyEvent_VK_RIGHT_PARENTHESIS: macKey = ')'; break;
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   325
            case java_awt_event_KeyEvent_VK_UNDERSCORE      : macKey = '_'; break;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   326
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   327
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   328
    return macKey;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   329
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   330
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   331
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   332
 * Class:     sun_lwawt_macosx_CMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   333
 * Method:    nativeSetLabel
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   334
 * Signature: (JLjava/lang/String;CII)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   335
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   336
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   337
Java_sun_lwawt_macosx_CMenuItem_nativeSetLabel
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   338
(JNIEnv *env, jobject peer,
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   339
 jlong menuItemObj, jstring label,
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   340
 jchar shortcutKey, jint shortcutKeyCode, jint mods)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   341
{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   342
    JNF_COCOA_ENTER(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   343
    NSString *theLabel = JNFJavaToNSString(env, label);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   344
    NSString *theKeyEquivalent = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   345
    unichar macKey = shortcutKey;
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   346
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   347
    if (macKey == 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   348
        macKey = AWTKeyToMacShortcut(shortcutKeyCode, (mods & java_awt_event_KeyEvent_SHIFT_MASK) != 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   349
    }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   350
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   351
    if (macKey != 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   352
        unichar equivalent[1] = {macKey};
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   353
        theKeyEquivalent = [NSString stringWithCharacters:equivalent length:1];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   354
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   355
        theKeyEquivalent = @"";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   356
    }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   357
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   358
    [((CMenuItem *)jlong_to_ptr(menuItemObj)) setJavaLabel:theLabel shortcut:theKeyEquivalent modifierMask:mods];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   359
    JNF_COCOA_EXIT(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   360
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   361
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   362
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   363
 * Class:     sun_lwawt_macosx_CMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   364
 * Method:    nativeSetTooltip
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   365
 * Signature: (JLjava/lang/String;)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   367
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
Java_sun_lwawt_macosx_CMenuItem_nativeSetTooltip
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
(JNIEnv *env, jobject peer, jlong menuItemObj, jstring tooltip)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   371
    JNF_COCOA_ENTER(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   372
    NSString *theTooltip = JNFJavaToNSString(env, tooltip);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   373
    [((CMenuItem *)jlong_to_ptr(menuItemObj)) setJavaToolTipText:theTooltip];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   374
    JNF_COCOA_EXIT(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   375
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   377
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
 * Class:     sun_lwawt_macosx_CMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   379
 * Method:    nativeSetImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   380
 * Signature: (JJ)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   381
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   382
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   383
Java_sun_lwawt_macosx_CMenuItem_nativeSetImage
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   384
(JNIEnv *env, jobject peer, jlong menuItemObj, jlong image)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   385
{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   386
    JNF_COCOA_ENTER(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   387
    [((CMenuItem *)jlong_to_ptr(menuItemObj)) setJavaImage:(NSImage*)jlong_to_ptr(image)];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   388
    JNF_COCOA_EXIT(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   389
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   390
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   391
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   392
 * Class:     sun_lwawt_macosx_CMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   393
 * Method:    nativeCreate
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   394
 * Signature: (JZ)J
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   395
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   396
JNIEXPORT jlong JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   397
Java_sun_lwawt_macosx_CMenuItem_nativeCreate
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   398
(JNIEnv *env, jobject peer, jlong parentCMenuObj, jboolean isSeparator)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   399
{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   400
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   401
    CMenuItem *aCMenuItem = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   402
    CMenu *parentCMenu = (CMenu *)jlong_to_ptr(parentCMenuObj);
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   403
    JNF_COCOA_ENTER(env);
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   404
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   405
    jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   406
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   407
    NSMutableArray *args = nil;
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   408
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   409
    // Create a new item....
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   410
    if (isSeparator == JNI_TRUE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   411
        args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:YES],  nil];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   412
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
        args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:NO],  nil];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
    }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   415
    
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   416
    [ThreadUtilities performOnMainThread:@selector(_createMenuItem_OnAppKitThread:) on:[CMenuItem alloc] withObject:args waitUntilDone:YES];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   417
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
    aCMenuItem = (CMenuItem *)[args objectAtIndex: 0];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   419
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
    if (aCMenuItem == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   421
        return 0L;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   422
    }
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   423
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
    // and add it to the parent item.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
    [parentCMenu addJavaMenuItem: aCMenuItem];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   426
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
    // setLabel will be called after creation completes.
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   428
    
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   429
    JNF_COCOA_EXIT(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   430
    return ptr_to_jlong(aCMenuItem);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   431
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   433
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
 * Class:     sun_lwawt_macosx_CMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   435
 * Method:    nativeSetEnabled
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   436
 * Signature: (JZ)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   437
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   438
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
Java_sun_lwawt_macosx_CMenuItem_nativeSetEnabled
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   440
(JNIEnv *env, jobject peer, jlong menuItemObj, jboolean enable)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   441
{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   442
    JNF_COCOA_ENTER(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
    CMenuItem *item = (CMenuItem *)jlong_to_ptr(menuItemObj);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   444
    [item setJavaEnabled: (enable == JNI_TRUE)];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   445
    JNF_COCOA_EXIT(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   446
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   447
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   448
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   449
 * Class:     sun_lwawt_macosx_CCheckboxMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
 * Method:    nativeSetState
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   451
 * Signature: (IZ)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   452
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   454
Java_sun_lwawt_macosx_CCheckboxMenuItem_nativeSetState
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   455
(JNIEnv *env, jobject peer, jlong menuItemObj, jboolean state)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   456
{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   457
    JNF_COCOA_ENTER(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
    CMenuItem *item = (CMenuItem *)jlong_to_ptr(menuItemObj);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
    [item setJavaState: (state == JNI_TRUE)];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   460
    JNF_COCOA_EXIT(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   461
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   462
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   464
 * Class:     sun_lwawt_macosx_CCheckboxMenuItem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
 * Method:    nativeSetState
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
 * Signature: (IZ)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   467
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   468
JNIEXPORT void JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   469
Java_sun_lwawt_macosx_CCheckboxMenuItem_nativeSetIsCheckbox
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
(JNIEnv *env, jobject peer, jlong menuItemObj)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
{
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   472
    JNF_COCOA_ENTER(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
    CMenuItem *item = (CMenuItem *)jlong_to_ptr(menuItemObj);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   474
    [item setIsCheckbox];
34809
cfc824c24939 8139169: [macosx] Action registered for keyboard shortcut is called twice
aniyogi
parents: 26751
diff changeset
   475
    JNF_COCOA_EXIT(env);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   476
}