src/macosx/native/sun/awt/AWTEvent.m
Print this page
*** 306,315 ****
--- 306,318 ----
/*
* Almost all unicode characters just go from NS to Java with no translation.
* For the few exceptions, we handle it here with this small table.
*/
+ #define ALL_NS_KEY_MODIFIERS_MASK \
+ (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
+
static struct _char {
NSUInteger modifier;
unichar nsChar;
unichar javaChar;
}
*** 319,330 ****
// [3134616] return newline instead of carriage return
{0, NSCarriageReturnCharacter, NSNewlineCharacter},
// "delete" means backspace in Java
! {0, NSDeleteCharacter, NSBackspaceCharacter},
! {0, NSDeleteFunctionKey, NSDeleteCharacter},
// back-tab is only differentiated from tab by Shift flag
{NSShiftKeyMask, NSBackTabCharacter, NSTabCharacter},
{0, 0, 0}
--- 322,333 ----
// [3134616] return newline instead of carriage return
{0, NSCarriageReturnCharacter, NSNewlineCharacter},
// "delete" means backspace in Java
! {ALL_NS_KEY_MODIFIERS_MASK, NSDeleteCharacter, NSBackspaceCharacter},
! {ALL_NS_KEY_MODIFIERS_MASK, NSDeleteFunctionKey, NSDeleteCharacter},
// back-tab is only differentiated from tab by Shift flag
{NSShiftKeyMask, NSBackTabCharacter, NSTabCharacter},
{0, 0, 0}
*** 332,347 ****
static unichar
NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
{
const struct _char *cur;
- NSUInteger keyModifierFlags =
- NSShiftKeyMask | NSControlKeyMask |
- NSAlternateKeyMask | NSCommandKeyMask;
-
// Mask off just the keyboard modifiers from the event modifier mask.
! NSUInteger testableFlags = (modifiers & keyModifierFlags);
// walk through table & find the match
for (cur = charTable; cur->nsChar != 0 ; cur++) {
// <rdar://Problem/3476426> Need to determine if we are looking at
// a plain keypress or a modified keypress. Don't adjust the
--- 335,346 ----
static unichar
NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
{
const struct _char *cur;
// Mask off just the keyboard modifiers from the event modifier mask.
! NSUInteger testableFlags = (modifiers & ALL_NS_KEY_MODIFIERS_MASK);
// walk through table & find the match
for (cur = charTable; cur->nsChar != 0 ; cur++) {
// <rdar://Problem/3476426> Need to determine if we are looking at
// a plain keypress or a modified keypress. Don't adjust the
*** 1067,1071 ****
--- 1066,1090 ----
(*env)->ReleaseIntArrayElements(env, inData, data, 0);
JNF_COCOA_EXIT(env);
}
+
+ /*
+ * Class: sun_lwawt_macosx_event_NSEvent
+ * Method: nsToJavaChar
+ * Signature: (CI)C
+ */
+ JNIEXPORT jint JNICALL
+ Java_sun_lwawt_macosx_event_NSEvent_nsToJavaChar
+ (JNIEnv *env, jclass cls, char nsChar, jint modifierFlags)
+ {
+ jchar javaChar = 0;
+
+ JNF_COCOA_ENTER(env);
+
+ javaChar = NsCharToJavaChar(nsChar, modifierFlags);
+
+ JNF_COCOA_EXIT(env);
+
+ return javaChar;
+ }