mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 20:03:39 +00:00
7156316: [macosx] Ctrl+Space does generate Unknown keychar
Reviewed-by: alexsch, aniyogi
This commit is contained in:
parent
3c449e081f
commit
6132b8f774
@ -135,6 +135,7 @@ final class CPlatformResponder {
|
||||
int jkeyCode = KeyEvent.VK_UNDEFINED;
|
||||
int jkeyLocation = KeyEvent.KEY_LOCATION_UNKNOWN;
|
||||
boolean postsTyped = false;
|
||||
boolean spaceKeyTyped = false;
|
||||
|
||||
char testChar = KeyEvent.CHAR_UNDEFINED;
|
||||
boolean isDeadChar = (chars!= null && chars.length() == 0);
|
||||
@ -151,6 +152,11 @@ final class CPlatformResponder {
|
||||
} else {
|
||||
if (chars != null && chars.length() > 0) {
|
||||
testChar = chars.charAt(0);
|
||||
|
||||
//Check if String chars contains SPACE character.
|
||||
if (chars.trim().isEmpty()) {
|
||||
spaceKeyTyped = true;
|
||||
}
|
||||
}
|
||||
|
||||
char testCharIgnoringModifiers = charsIgnoringModifiers != null && charsIgnoringModifiers.length() > 0 ?
|
||||
@ -187,7 +193,7 @@ final class CPlatformResponder {
|
||||
NSEvent.nsToJavaEventType(eventType);
|
||||
}
|
||||
|
||||
char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
|
||||
char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags, spaceKeyTyped);
|
||||
// Some keys may generate a KEY_TYPED, but we can't determine
|
||||
// what that character is. That's likely a bug, but for now we
|
||||
// just check for CHAR_UNDEFINED.
|
||||
|
||||
@ -254,7 +254,7 @@ final class NSEvent {
|
||||
* There is a small number of NS characters that need to be converted
|
||||
* into other characters before we pass them to AWT.
|
||||
*/
|
||||
static native char nsToJavaChar(char nsChar, int modifierFlags);
|
||||
static native char nsToJavaChar(char nsChar, int modifierFlags, boolean spaceKeyTyped);
|
||||
|
||||
static boolean isPopupTrigger(int jmodifiers) {
|
||||
final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
|
||||
|
||||
@ -349,7 +349,7 @@ const charTable[] = {
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
|
||||
unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers, BOOL spaceKeyTyped)
|
||||
{
|
||||
const struct _char *cur;
|
||||
// Mask off just the keyboard modifiers from the event modifier mask.
|
||||
@ -382,6 +382,11 @@ unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
|
||||
return java_awt_event_KeyEvent_CHAR_UNDEFINED;
|
||||
}
|
||||
|
||||
// nsChar receives value 0 when SPACE key is typed.
|
||||
if (nsChar == 0 && spaceKeyTyped == YES) {
|
||||
return java_awt_event_KeyEvent_VK_SPACE;
|
||||
}
|
||||
|
||||
// otherwise return character unchanged
|
||||
return nsChar;
|
||||
}
|
||||
@ -757,13 +762,13 @@ JNF_COCOA_EXIT(env);
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_sun_lwawt_macosx_NSEvent_nsToJavaChar
|
||||
(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags)
|
||||
(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags, jboolean spaceKeyTyped)
|
||||
{
|
||||
jchar javaChar = 0;
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
javaChar = NsCharToJavaChar(nsChar, modifierFlags);
|
||||
javaChar = NsCharToJavaChar(nsChar, modifierFlags, spaceKeyTyped);
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user