8149456: [macosx] robot.keyPress do not generate key events (keyPressed and keyReleased) for function keys F13 to F19
Reviewed-by: ssadetsky, aniyogi
This commit is contained in:
parent
495a192c69
commit
062ae66672
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,12 +29,12 @@
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#import "CRobotKeyCode.h"
|
||||
#import "LWCToolkit.h"
|
||||
#import "sun_lwawt_macosx_CRobot.h"
|
||||
#import "java_awt_event_InputEvent.h"
|
||||
#import "sizecalc.h"
|
||||
|
||||
|
||||
// Starting number for event numbers generated by Robot.
|
||||
// Apple docs don't mention at all what are the requirements
|
||||
// for these numbers. It seems that they must be higher
|
||||
@ -354,241 +354,10 @@ static void PostMouseEvent(const CGPoint point, CGMouseButton button,
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Don't modify this table directly. It is machine generated. See below.
|
||||
static const unsigned char javaToMacKeyCode[] = {
|
||||
127, // 0 0 VK_UNDEFINED No_Equivalent
|
||||
127, // 1 0x1 Not_Used
|
||||
127, // 2 0x2 Not_Used
|
||||
127, // 3 0x3 VK_CANCEL No_Equivalent
|
||||
127, // 4 0x4 Not_Used
|
||||
127, // 5 0x5 Not_Used
|
||||
127, // 6 0x6 Not_Used
|
||||
127, // 7 0x7 Not_Used
|
||||
51, // 8 0x8 VK_BACK_SPACE
|
||||
48, // 9 0x9 VK_TAB
|
||||
36, // 10 0xa VK_ENTER
|
||||
127, // 11 0xb Not_Used
|
||||
71, // 12 0xc VK_CLEAR
|
||||
127, // 13 0xd Not_Used
|
||||
127, // 14 0xe Not_Used
|
||||
127, // 15 0xf Not_Used
|
||||
56, // 16 0x10 VK_SHIFT
|
||||
59, // 17 0x11 VK_CONTROL
|
||||
58, // 18 0x12 VK_ALT
|
||||
113, // 19 0x13 VK_PAUSE
|
||||
57, // 20 0x14 VK_CAPS_LOCK
|
||||
127, // 21 0x15 VK_KANA No_Equivalent
|
||||
127, // 22 0x16 Not_Used
|
||||
127, // 23 0x17 Not_Used
|
||||
127, // 24 0x18 VK_FINAL No_Equivalent
|
||||
127, // 25 0x19 VK_KANJI No_Equivalent
|
||||
127, // 26 0x1a Not_Used
|
||||
53, // 27 0x1b VK_ESCAPE
|
||||
127, // 28 0x1c VK_CONVERT No_Equivalent
|
||||
127, // 29 0x1d VK_NONCONVERT No_Equivalent
|
||||
127, // 30 0x1e VK_ACCEPT No_Equivalent
|
||||
127, // 31 0x1f VK_MODECHANGE No_Equivalent
|
||||
49, // 32 0x20 VK_SPACE
|
||||
116, // 33 0x21 VK_PAGE_UP
|
||||
121, // 34 0x22 VK_PAGE_DOWN
|
||||
119, // 35 0x23 VK_END
|
||||
115, // 36 0x24 VK_HOME
|
||||
123, // 37 0x25 VK_LEFT
|
||||
126, // 38 0x26 VK_UP
|
||||
124, // 39 0x27 VK_RIGHT
|
||||
125, // 40 0x28 VK_DOWN
|
||||
127, // 41 0x29 Not_Used
|
||||
127, // 42 0x2a Not_Used
|
||||
127, // 43 0x2b Not_Used
|
||||
43, // 44 0x2c VK_COMMA
|
||||
27, // 45 0x2d VK_MINUS
|
||||
47, // 46 0x2e VK_PERIOD
|
||||
44, // 47 0x2f VK_SLASH
|
||||
29, // 48 0x30 VK_0
|
||||
18, // 49 0x31 VK_1
|
||||
19, // 50 0x32 VK_2
|
||||
20, // 51 0x33 VK_3
|
||||
21, // 52 0x34 VK_4
|
||||
23, // 53 0x35 VK_5
|
||||
22, // 54 0x36 VK_6
|
||||
26, // 55 0x37 VK_7
|
||||
28, // 56 0x38 VK_8
|
||||
25, // 57 0x39 VK_9
|
||||
127, // 58 0x3a Not_Used
|
||||
41, // 59 0x3b VK_SEMICOLON
|
||||
127, // 60 0x3c Not_Used
|
||||
24, // 61 0x3d VK_EQUALS
|
||||
127, // 62 0x3e Not_Used
|
||||
127, // 63 0x3f Not_Used
|
||||
127, // 64 0x40 Not_Used
|
||||
0, // 65 0x41 VK_A
|
||||
11, // 66 0x42 VK_B
|
||||
8, // 67 0x43 VK_C
|
||||
2, // 68 0x44 VK_D
|
||||
14, // 69 0x45 VK_E
|
||||
3, // 70 0x46 VK_F
|
||||
5, // 71 0x47 VK_G
|
||||
4, // 72 0x48 VK_H
|
||||
34, // 73 0x49 VK_I
|
||||
38, // 74 0x4a VK_J
|
||||
40, // 75 0x4b VK_K
|
||||
37, // 76 0x4c VK_L
|
||||
46, // 77 0x4d VK_M
|
||||
45, // 78 0x4e VK_N
|
||||
31, // 79 0x4f VK_O
|
||||
35, // 80 0x50 VK_P
|
||||
12, // 81 0x51 VK_Q
|
||||
15, // 82 0x52 VK_R
|
||||
1, // 83 0x53 VK_S
|
||||
17, // 84 0x54 VK_T
|
||||
32, // 85 0x55 VK_U
|
||||
9, // 86 0x56 VK_V
|
||||
13, // 87 0x57 VK_W
|
||||
7, // 88 0x58 VK_X
|
||||
16, // 89 0x59 VK_Y
|
||||
6, // 90 0x5a VK_Z
|
||||
33, // 91 0x5b VK_OPEN_BRACKET
|
||||
42, // 92 0x5c VK_BACK_SLASH
|
||||
30, // 93 0x5d VK_CLOSE_BRACKET
|
||||
127, // 94 0x5e Not_Used
|
||||
127, // 95 0x5f Not_Used
|
||||
82, // 96 0x60 VK_NUMPAD0
|
||||
83, // 97 0x61 VK_NUMPAD1
|
||||
84, // 98 0x62 VK_NUMPAD2
|
||||
85, // 99 0x63 VK_NUMPAD3
|
||||
86, // 100 0x64 VK_NUMPAD4
|
||||
87, // 101 0x65 VK_NUMPAD5
|
||||
88, // 102 0x66 VK_NUMPAD6
|
||||
89, // 103 0x67 VK_NUMPAD7
|
||||
91, // 104 0x68 VK_NUMPAD8
|
||||
92, // 105 0x69 VK_NUMPAD9
|
||||
67, // 106 0x6a VK_MULTIPLY
|
||||
69, // 107 0x6b VK_ADD
|
||||
127, // 108 0x6c VK_SEPARATER No_Equivalent
|
||||
78, // 109 0x6d VK_SUBTRACT
|
||||
65, // 110 0x6e VK_DECIMAL
|
||||
75, // 111 0x6f VK_DIVIDE
|
||||
122, // 112 0x70 VK_F1
|
||||
120, // 113 0x71 VK_F2
|
||||
99, // 114 0x72 VK_F3
|
||||
118, // 115 0x73 VK_F4
|
||||
96, // 116 0x74 VK_F5
|
||||
97, // 117 0x75 VK_F6
|
||||
98, // 118 0x76 VK_F7
|
||||
100, // 119 0x77 VK_F8
|
||||
101, // 120 0x78 VK_F9
|
||||
109, // 121 0x79 VK_F10
|
||||
103, // 122 0x7a VK_F11
|
||||
111, // 123 0x7b VK_F12
|
||||
127, // 124 0x7c Not_Used
|
||||
127, // 125 0x7d Not_Used
|
||||
127, // 126 0x7e Not_Used
|
||||
117, // 127 0x7f VK_DELETE
|
||||
127, // 128 0x80 VK_DEAD_GRAVE No_Equivalent
|
||||
127, // 129 0x81 VK_DEAD_ACUTE No_Equivalent
|
||||
127, // 130 0x82 VK_DEAD_CIRCUMFLEX No_Equivalent
|
||||
127, // 131 0x83 VK_DEAD_TILDE No_Equivalent
|
||||
127, // 132 0x84 VK_DEAD_MACRON No_Equivalent
|
||||
127, // 133 0x85 VK_DEAD_BREVE No_Equivalent
|
||||
127, // 134 0x86 VK_DEAD_ABOVEDOT No_Equivalent
|
||||
127, // 135 0x87 VK_DEAD_DIAERESIS No_Equivalent
|
||||
127, // 136 0x88 VK_DEAD_ABOVERING No_Equivalent
|
||||
127, // 137 0x89 VK_DEAD_DOUBLEACUTE No_Equivalent
|
||||
127, // 138 0x8a VK_DEAD_CARON No_Equivalent
|
||||
127, // 139 0x8b VK_DEAD_CEDILLA No_Equivalent
|
||||
127, // 140 0x8c VK_DEAD_OGONEK No_Equivalent
|
||||
127, // 141 0x8d VK_DEAD_IOTA No_Equivalent
|
||||
127, // 142 0x8e VK_DEAD_VOICED_SOUND No_Equivalent
|
||||
127, // 143 0x8f VK_DEAD_SEMIVOICED_SOUND No_Equivalent
|
||||
127, // 144 0x90 VK_NUM_LOCK No_Equivalent
|
||||
107, // 145 0x91 VK_SCROLL_LOCK
|
||||
127, // 146 0x92 Not_Used
|
||||
127, // 147 0x93 Not_Used
|
||||
127, // 148 0x94 Not_Used
|
||||
127, // 149 0x95 Not_Used
|
||||
127, // 150 0x96 VK_AMPERSAND No_Equivalent
|
||||
127, // 151 0x97 VK_ASTERISK No_Equivalent
|
||||
127, // 152 0x98 VK_QUOTEDBL No_Equivalent
|
||||
127, // 153 0x99 VK_LESS No_Equivalent
|
||||
105, // 154 0x9a VK_PRINTSCREEN
|
||||
127, // 155 0x9b VK_INSERT No_Equivalent
|
||||
114, // 156 0x9c VK_HELP
|
||||
55, // 157 0x9d VK_META
|
||||
127, // 158 0x9e Not_Used
|
||||
127, // 159 0x9f Not_Used
|
||||
127, // 160 0xa0 VK_GREATER No_Equivalent
|
||||
127, // 161 0xa1 VK_BRACELEFT No_Equivalent
|
||||
127, // 162 0xa2 VK_BRACERIGHT No_Equivalent
|
||||
127, // 163 0xa3 Not_Used
|
||||
127, // 164 0xa4 Not_Used
|
||||
127, // 165 0xa5 Not_Used
|
||||
127, // 166 0xa6 Not_Used
|
||||
127, // 167 0xa7 Not_Used
|
||||
127, // 168 0xa8 Not_Used
|
||||
127, // 169 0xa9 Not_Used
|
||||
127, // 170 0xaa Not_Used
|
||||
127, // 171 0xab Not_Used
|
||||
127, // 172 0xac Not_Used
|
||||
127, // 173 0xad Not_Used
|
||||
127, // 174 0xae Not_Used
|
||||
127, // 175 0xaf Not_Used
|
||||
127, // 176 0xb0 Not_Used
|
||||
127, // 177 0xb1 Not_Used
|
||||
127, // 178 0xb2 Not_Used
|
||||
127, // 179 0xb3 Not_Used
|
||||
127, // 180 0xb4 Not_Used
|
||||
127, // 181 0xb5 Not_Used
|
||||
127, // 182 0xb6 Not_Used
|
||||
127, // 183 0xb7 Not_Used
|
||||
127, // 184 0xb8 Not_Used
|
||||
127, // 185 0xb9 Not_Used
|
||||
127, // 186 0xba Not_Used
|
||||
127, // 187 0xbb Not_Used
|
||||
127, // 188 0xbc Not_Used
|
||||
127, // 189 0xbd Not_Used
|
||||
127, // 190 0xbe Not_Used
|
||||
127, // 191 0xbf Not_Used
|
||||
50, // 192 0xc0 VK_BACK_QUOTE
|
||||
127, // 193 0xc1 Not_Used
|
||||
127, // 194 0xc2 Not_Used
|
||||
127, // 195 0xc3 Not_Used
|
||||
127, // 196 0xc4 Not_Used
|
||||
127, // 197 0xc5 Not_Used
|
||||
127, // 198 0xc6 Not_Used
|
||||
127, // 199 0xc7 Not_Used
|
||||
127, // 200 0xc8 Not_Used
|
||||
127, // 201 0xc9 Not_Used
|
||||
127, // 202 0xca Not_Used
|
||||
127, // 203 0xcb Not_Used
|
||||
127, // 204 0xcc Not_Used
|
||||
127, // 205 0xcd Not_Used
|
||||
127, // 206 0xce Not_Used
|
||||
127, // 207 0xcf Not_Used
|
||||
127, // 208 0xd0 Not_Used
|
||||
127, // 209 0xd1 Not_Used
|
||||
127, // 210 0xd2 Not_Used
|
||||
127, // 211 0xd3 Not_Used
|
||||
127, // 212 0xd4 Not_Used
|
||||
127, // 213 0xd5 Not_Used
|
||||
127, // 214 0xd6 Not_Used
|
||||
127, // 215 0xd7 Not_Used
|
||||
127, // 216 0xd8 Not_Used
|
||||
127, // 217 0xd9 Not_Used
|
||||
127, // 218 0xda Not_Used
|
||||
127, // 219 0xdb Not_Used
|
||||
127, // 220 0xdc Not_Used
|
||||
127, // 221 0xdd Not_Used
|
||||
39 // 222 0xde VK_QUOTE
|
||||
};
|
||||
|
||||
// NOTE: All values above 222 don't have an equivalent on MacOSX.
|
||||
static inline CGKeyCode GetCGKeyCode(jint javaKeyCode)
|
||||
{
|
||||
if (javaKeyCode > 222) {
|
||||
return 127;
|
||||
} else {
|
||||
return javaToMacKeyCode[javaKeyCode];
|
||||
}
|
||||
CRobotKeyCodeMapping *keyCodeMapping = [CRobotKeyCodeMapping sharedInstance];
|
||||
return [keyCodeMapping getOSXKeyCodeForJavaKey:javaKeyCode];
|
||||
}
|
||||
|
||||
static int GetClickCount(BOOL isDown) {
|
||||
|
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifndef KeyCodeConverter_CRobotKeyCode_h
|
||||
#define KeyCodeConverter_CRobotKeyCode_h
|
||||
|
||||
const static int OSX_kVK_ANSI_A = 0x00;
|
||||
const static int OSX_kVK_ANSI_S = 0x01;
|
||||
const static int OSX_kVK_ANSI_D = 0x02;
|
||||
const static int OSX_kVK_ANSI_F = 0x03;
|
||||
const static int OSX_kVK_ANSI_H = 0x04;
|
||||
const static int OSX_kVK_ANSI_G = 0x05;
|
||||
const static int OSX_kVK_ANSI_Z = 0x06;
|
||||
const static int OSX_kVK_ANSI_X = 0x07;
|
||||
const static int OSX_kVK_ANSI_C = 0x08;
|
||||
const static int OSX_kVK_ANSI_V = 0x09;
|
||||
const static int OSX_kVK_ISO_Section = 0x0A;
|
||||
const static int OSX_kVK_ANSI_B = 0x0B;
|
||||
const static int OSX_kVK_ANSI_Q = 0x0C;
|
||||
const static int OSX_kVK_ANSI_W = 0x0D;
|
||||
const static int OSX_kVK_ANSI_E = 0x0E;
|
||||
const static int OSX_kVK_ANSI_R = 0x0F;
|
||||
const static int OSX_kVK_ANSI_Y = 0x10;
|
||||
const static int OSX_kVK_ANSI_T = 0x11;
|
||||
const static int OSX_kVK_ANSI_1 = 0x12;
|
||||
const static int OSX_kVK_ANSI_2 = 0x13;
|
||||
const static int OSX_kVK_ANSI_3 = 0x14;
|
||||
const static int OSX_kVK_ANSI_4 = 0x15;
|
||||
const static int OSX_kVK_ANSI_6 = 0x16;
|
||||
const static int OSX_kVK_ANSI_5 = 0x17;
|
||||
const static int OSX_kVK_ANSI_Equal = 0x18;
|
||||
const static int OSX_kVK_ANSI_9 = 0x19;
|
||||
const static int OSX_kVK_ANSI_7 = 0x1A;
|
||||
const static int OSX_kVK_ANSI_Minus = 0x1B;
|
||||
const static int OSX_kVK_ANSI_8 = 0x1C;
|
||||
const static int OSX_kVK_ANSI_0 = 0x1D;
|
||||
const static int OSX_kVK_ANSI_RightBracket = 0x1E;
|
||||
const static int OSX_kVK_ANSI_O = 0x1F;
|
||||
const static int OSX_kVK_ANSI_U = 0x20;
|
||||
const static int OSX_kVK_ANSI_LeftBracket = 0x21;
|
||||
const static int OSX_kVK_ANSI_I = 0x22;
|
||||
const static int OSX_kVK_ANSI_P = 0x23;
|
||||
const static int OSX_kVK_ANSI_L = 0x25;
|
||||
const static int OSX_kVK_ANSI_J = 0x26;
|
||||
const static int OSX_kVK_ANSI_Quote = 0x27;
|
||||
const static int OSX_kVK_ANSI_K = 0x28;
|
||||
const static int OSX_kVK_ANSI_Semicolon = 0x29;
|
||||
const static int OSX_kVK_ANSI_Backslash = 0x2A;
|
||||
const static int OSX_kVK_ANSI_Comma = 0x2B;
|
||||
const static int OSX_kVK_ANSI_Slash = 0x2C;
|
||||
const static int OSX_kVK_ANSI_N = 0x2D;
|
||||
const static int OSX_kVK_ANSI_M = 0x2E;
|
||||
const static int OSX_kVK_ANSI_Period = 0x2F;
|
||||
const static int OSX_kVK_ANSI_Grave = 0x32;
|
||||
const static int OSX_kVK_ANSI_KeypadDecimal = 0x41;
|
||||
const static int OSX_kVK_ANSI_KeypadMultiply = 0x43;
|
||||
const static int OSX_kVK_ANSI_KeypadPlus = 0x45;
|
||||
const static int OSX_kVK_ANSI_KeypadClear = 0x47;
|
||||
const static int OSX_kVK_ANSI_KeypadDivide = 0x4B;
|
||||
const static int OSX_kVK_ANSI_KeypadEnter = 0x4C;
|
||||
const static int OSX_kVK_ANSI_KeypadMinus = 0x4E;
|
||||
const static int OSX_kVK_ANSI_KeypadEquals = 0x51;
|
||||
const static int OSX_kVK_ANSI_Keypad0 = 0x52;
|
||||
const static int OSX_kVK_ANSI_Keypad1 = 0x53;
|
||||
const static int OSX_kVK_ANSI_Keypad2 = 0x54;
|
||||
const static int OSX_kVK_ANSI_Keypad3 = 0x55;
|
||||
const static int OSX_kVK_ANSI_Keypad4 = 0x56;
|
||||
const static int OSX_kVK_ANSI_Keypad5 = 0x57;
|
||||
const static int OSX_kVK_ANSI_Keypad6 = 0x58;
|
||||
const static int OSX_kVK_ANSI_Keypad7 = 0x59;
|
||||
const static int OSX_kVK_ANSI_Keypad8 = 0x5B;
|
||||
const static int OSX_kVK_ANSI_Keypad9 = 0x5C;
|
||||
const static int OSX_kVK_Return = 0x24;
|
||||
const static int OSX_kVK_Tab = 0x30;
|
||||
const static int OSX_kVK_Space = 0x31;
|
||||
const static int OSX_Delete = 0x33;
|
||||
const static int OSX_Escape = 0x35;
|
||||
const static int OSX_Command = 0x37;
|
||||
const static int OSX_Shift = 0x38;
|
||||
const static int OSX_CapsLock = 0x39;
|
||||
const static int OSX_Option = 0x3A;
|
||||
const static int OSX_Control = 0x3B;
|
||||
const static int OSX_RightShift = 0x3C;
|
||||
const static int OSX_RightOption = 0x3D;
|
||||
const static int OSX_RightControl = 0x3E;
|
||||
const static int OSX_Function = 0x3F;
|
||||
const static int OSX_F17 = 0x40;
|
||||
const static int OSX_VolumeUp = 0x48;
|
||||
const static int OSX_VolumeDown = 0x49;
|
||||
const static int OSX_Mute = 0x4A;
|
||||
const static int OSX_F18 = 0x4F;
|
||||
const static int OSX_F19 = 0x50;
|
||||
const static int OSX_F20 = 0x5A;
|
||||
const static int OSX_F5 = 0x60;
|
||||
const static int OSX_F6 = 0x61;
|
||||
const static int OSX_F7 = 0x62;
|
||||
const static int OSX_F3 = 0x63;
|
||||
const static int OSX_F8 = 0x64;
|
||||
const static int OSX_F9 = 0x65;
|
||||
const static int OSX_F11 = 0x67;
|
||||
const static int OSX_F13 = 0x69;
|
||||
const static int OSX_F16 = 0x6A;
|
||||
const static int OSX_F14 = 0x6B;
|
||||
const static int OSX_F10 = 0x6D;
|
||||
const static int OSX_F12 = 0x6F;
|
||||
const static int OSX_F15 = 0x71;
|
||||
const static int OSX_Help = 0x72;
|
||||
const static int OSX_Home = 0x73;
|
||||
const static int OSX_PageUp = 0x74;
|
||||
const static int OSX_ForwardDelete = 0x75;
|
||||
const static int OSX_F4 = 0x76;
|
||||
const static int OSX_End = 0x77;
|
||||
const static int OSX_F2 = 0x78;
|
||||
const static int OSX_PageDown = 0x79;
|
||||
const static int OSX_F1 = 0x7A;
|
||||
const static int OSX_LeftArrow = 0x7B;
|
||||
const static int OSX_RightArrow = 0x7C;
|
||||
const static int OSX_DownArrow = 0x7D;
|
||||
const static int OSX_UpArrow = 0x7E;
|
||||
const static int OSX_Undefined = 0x7F;
|
||||
|
||||
@interface CRobotKeyCodeMapping : NSObject {
|
||||
|
||||
}
|
||||
|
||||
@property (readwrite, retain) NSDictionary *javaToMacKeyMap;
|
||||
|
||||
+ (CRobotKeyCodeMapping *)sharedInstance ;
|
||||
- (int)getOSXKeyCodeForJavaKey:(int) javaKey;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#import "CRobotKeyCode.h"
|
||||
#import "java_awt_event_KeyEvent.h"
|
||||
|
||||
@implementation CRobotKeyCodeMapping
|
||||
|
||||
@synthesize javaToMacKeyMap;
|
||||
|
||||
+(CRobotKeyCodeMapping *) sharedInstance {
|
||||
static CRobotKeyCodeMapping *instance = nil;
|
||||
static dispatch_once_t executeOnce;
|
||||
|
||||
dispatch_once(&executeOnce, ^{
|
||||
instance = [[CRobotKeyCodeMapping alloc] init];
|
||||
});
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
-(id) init {
|
||||
self = [super init];
|
||||
|
||||
if (nil != self) {
|
||||
javaToMacKeyMap = [NSDictionary dictionaryWithObjectsAndKeys :
|
||||
[NSNumber numberWithInt : OSX_Delete], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_BACK_SPACE],
|
||||
[NSNumber numberWithInt : OSX_kVK_Tab], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_TAB],
|
||||
[NSNumber numberWithInt : OSX_kVK_Return], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ENTER],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_KeypadClear], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CLEAR],
|
||||
[NSNumber numberWithInt : OSX_Shift], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SHIFT],
|
||||
[NSNumber numberWithInt : OSX_Control], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CONTROL],
|
||||
[NSNumber numberWithInt : OSX_Option], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ALT],
|
||||
[NSNumber numberWithInt : OSX_CapsLock], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CAPS_LOCK],
|
||||
[NSNumber numberWithInt : OSX_Escape], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ESCAPE],
|
||||
[NSNumber numberWithInt : OSX_kVK_Space], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SPACE],
|
||||
[NSNumber numberWithInt : OSX_PageUp], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_PAGE_UP],
|
||||
[NSNumber numberWithInt : OSX_PageDown], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_PAGE_DOWN],
|
||||
[NSNumber numberWithInt : OSX_End], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_END],
|
||||
[NSNumber numberWithInt : OSX_Home], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_HOME],
|
||||
[NSNumber numberWithInt : OSX_LeftArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_LEFT],
|
||||
[NSNumber numberWithInt : OSX_UpArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_UP],
|
||||
[NSNumber numberWithInt : OSX_RightArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_RIGHT],
|
||||
[NSNumber numberWithInt : OSX_DownArrow], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DOWN],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Comma], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_COMMA],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Minus], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_MINUS],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Period], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_PERIOD],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Slash], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SLASH],
|
||||
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_0], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_0],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_1], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_1],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_2], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_2],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_3], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_3],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_4], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_4],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_5], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_5],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_6], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_6],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_7], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_7],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_8], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_8],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_9], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_9],
|
||||
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Semicolon], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SEMICOLON],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Equal], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_EQUALS],
|
||||
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_A], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_A],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_B], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_B],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_C], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_C],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_D], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_D],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_E], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_E],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_F], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_G], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_G],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_H], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_H],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_I], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_I],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_J], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_J],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_K], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_K],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_L], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_L],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_M], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_M],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_N], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_N],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_O], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_O],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_P], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_P],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Q], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_Q],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_R], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_R],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_S], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_S],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_T], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_T],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_U], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_U],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_V], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_V],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_W], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_W],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_X], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_X],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Y], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_Y],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Z], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_Z],
|
||||
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_LeftBracket], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_OPEN_BRACKET],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Backslash], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_BACK_SLASH],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_RightBracket], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_CLOSE_BRACKET],
|
||||
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad0], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD0],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad1], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD1],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad2], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD2],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad3], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD3],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad4], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD4],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad5], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD5],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad6], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD6],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad7], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD7],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad8], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD8],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Keypad9], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_NUMPAD9],
|
||||
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_KeypadMultiply], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_MULTIPLY],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_KeypadPlus], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ADD],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_KeypadMinus], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_SUBTRACT],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_KeypadDecimal], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DECIMAL],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_KeypadDivide], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DIVIDE],
|
||||
|
||||
[NSNumber numberWithInt : OSX_F1], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F1],
|
||||
[NSNumber numberWithInt : OSX_F2], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F2],
|
||||
[NSNumber numberWithInt : OSX_F3], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F3],
|
||||
[NSNumber numberWithInt : OSX_F4], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F4],
|
||||
[NSNumber numberWithInt : OSX_F5], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F5],
|
||||
[NSNumber numberWithInt : OSX_F6], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F6],
|
||||
[NSNumber numberWithInt : OSX_F7], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F7],
|
||||
[NSNumber numberWithInt : OSX_F8], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F8],
|
||||
[NSNumber numberWithInt : OSX_F9], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F9],
|
||||
[NSNumber numberWithInt : OSX_F10], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F10],
|
||||
[NSNumber numberWithInt : OSX_F11], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F11],
|
||||
[NSNumber numberWithInt : OSX_F12], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F12],
|
||||
|
||||
[NSNumber numberWithInt : OSX_ForwardDelete], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_DELETE],
|
||||
[NSNumber numberWithInt : OSX_Help], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_HELP],
|
||||
[NSNumber numberWithInt : OSX_Command], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_META],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Grave], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_BACK_QUOTE],
|
||||
[NSNumber numberWithInt : OSX_kVK_ANSI_Quote], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_QUOTE],
|
||||
|
||||
[NSNumber numberWithInt : OSX_F13], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F13],
|
||||
[NSNumber numberWithInt : OSX_F14], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F14],
|
||||
[NSNumber numberWithInt : OSX_F15], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F15],
|
||||
[NSNumber numberWithInt : OSX_F16], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F16],
|
||||
[NSNumber numberWithInt : OSX_F17], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F17],
|
||||
[NSNumber numberWithInt : OSX_F18], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F18],
|
||||
[NSNumber numberWithInt : OSX_F19], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F19],
|
||||
[NSNumber numberWithInt : OSX_F20], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_F20],
|
||||
|
||||
nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(int) getOSXKeyCodeForJavaKey : (int) javaKey {
|
||||
id val = [javaToMacKeyMap objectForKey : [NSNumber numberWithInt : javaKey]];
|
||||
|
||||
if (nil != val) {
|
||||
return [val intValue];
|
||||
} else {
|
||||
return OSX_Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
227
jdk/test/java/awt/keyboard/AllKeyCode/AllKeyCode.java
Normal file
227
jdk/test/java/awt/keyboard/AllKeyCode/AllKeyCode.java
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
@test
|
||||
@bug 8149456 8147834 8150230
|
||||
@requires os.family == "mac"
|
||||
@summary KeyEvents for all keys
|
||||
@run main AllKeyCode
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.Frame;
|
||||
import java.awt.TextArea;
|
||||
|
||||
public class AllKeyCode extends Frame {
|
||||
|
||||
private static Frame frame;
|
||||
private static TextArea textArea;
|
||||
private static KeyListener keyListener;
|
||||
private static int allKeyArr[];
|
||||
private static int keyPressedIndex;
|
||||
|
||||
AllKeyCode() {
|
||||
AllKeyCode.allKeyArr = new int[] {
|
||||
KeyEvent.VK_BACK_SPACE,
|
||||
KeyEvent.VK_TAB,
|
||||
KeyEvent.VK_ENTER,
|
||||
KeyEvent.VK_CLEAR,
|
||||
KeyEvent.VK_SHIFT,
|
||||
KeyEvent.VK_CONTROL,
|
||||
KeyEvent.VK_ALT,
|
||||
KeyEvent.VK_CAPS_LOCK,
|
||||
KeyEvent.VK_ESCAPE,
|
||||
KeyEvent.VK_SPACE,
|
||||
KeyEvent.VK_PAGE_UP,
|
||||
KeyEvent.VK_PAGE_DOWN,
|
||||
KeyEvent.VK_END,
|
||||
KeyEvent.VK_HOME,
|
||||
KeyEvent.VK_LEFT,
|
||||
KeyEvent.VK_UP,
|
||||
KeyEvent.VK_RIGHT,
|
||||
KeyEvent.VK_DOWN,
|
||||
KeyEvent.VK_COMMA,
|
||||
KeyEvent.VK_MINUS,
|
||||
KeyEvent.VK_PERIOD,
|
||||
KeyEvent.VK_SLASH,
|
||||
KeyEvent.VK_0,
|
||||
KeyEvent.VK_1,
|
||||
KeyEvent.VK_2,
|
||||
KeyEvent.VK_3,
|
||||
KeyEvent.VK_4,
|
||||
KeyEvent.VK_5,
|
||||
KeyEvent.VK_6,
|
||||
KeyEvent.VK_7,
|
||||
KeyEvent.VK_8,
|
||||
KeyEvent.VK_9,
|
||||
KeyEvent.VK_SEMICOLON,
|
||||
KeyEvent.VK_EQUALS,
|
||||
KeyEvent.VK_A,
|
||||
KeyEvent.VK_B,
|
||||
KeyEvent.VK_C,
|
||||
KeyEvent.VK_D,
|
||||
KeyEvent.VK_E,
|
||||
KeyEvent.VK_F,
|
||||
KeyEvent.VK_G,
|
||||
KeyEvent.VK_H,
|
||||
KeyEvent.VK_I,
|
||||
KeyEvent.VK_J,
|
||||
KeyEvent.VK_K,
|
||||
KeyEvent.VK_L,
|
||||
KeyEvent.VK_M,
|
||||
KeyEvent.VK_N,
|
||||
KeyEvent.VK_O,
|
||||
KeyEvent.VK_P,
|
||||
KeyEvent.VK_Q,
|
||||
KeyEvent.VK_R,
|
||||
KeyEvent.VK_S,
|
||||
KeyEvent.VK_T,
|
||||
KeyEvent.VK_U,
|
||||
KeyEvent.VK_V,
|
||||
KeyEvent.VK_W,
|
||||
KeyEvent.VK_X,
|
||||
KeyEvent.VK_Y,
|
||||
KeyEvent.VK_Z,
|
||||
KeyEvent.VK_OPEN_BRACKET,
|
||||
KeyEvent.VK_BACK_SLASH,
|
||||
KeyEvent.VK_CLOSE_BRACKET,
|
||||
KeyEvent.VK_NUMPAD0,
|
||||
KeyEvent.VK_NUMPAD1,
|
||||
KeyEvent.VK_NUMPAD2,
|
||||
KeyEvent.VK_NUMPAD3,
|
||||
KeyEvent.VK_NUMPAD4,
|
||||
KeyEvent.VK_NUMPAD5,
|
||||
KeyEvent.VK_NUMPAD6,
|
||||
KeyEvent.VK_NUMPAD7,
|
||||
KeyEvent.VK_NUMPAD8,
|
||||
KeyEvent.VK_NUMPAD9,
|
||||
KeyEvent.VK_MULTIPLY,
|
||||
KeyEvent.VK_ADD,
|
||||
KeyEvent.VK_SUBTRACT,
|
||||
KeyEvent.VK_DECIMAL,
|
||||
KeyEvent.VK_DIVIDE,
|
||||
KeyEvent.VK_F1,
|
||||
KeyEvent.VK_F2,
|
||||
KeyEvent.VK_F3,
|
||||
KeyEvent.VK_F4,
|
||||
KeyEvent.VK_F5,
|
||||
KeyEvent.VK_F6,
|
||||
KeyEvent.VK_F7,
|
||||
KeyEvent.VK_F8,
|
||||
KeyEvent.VK_F9,
|
||||
KeyEvent.VK_F10,
|
||||
KeyEvent.VK_F11,
|
||||
KeyEvent.VK_F12,
|
||||
KeyEvent.VK_DELETE,
|
||||
KeyEvent.VK_HELP,
|
||||
KeyEvent.VK_META,
|
||||
KeyEvent.VK_BACK_QUOTE,
|
||||
KeyEvent.VK_QUOTE,
|
||||
KeyEvent.VK_F13,
|
||||
KeyEvent.VK_F14,
|
||||
KeyEvent.VK_F15,
|
||||
KeyEvent.VK_F16,
|
||||
KeyEvent.VK_F17,
|
||||
KeyEvent.VK_F18,
|
||||
KeyEvent.VK_F19,
|
||||
KeyEvent.VK_F20
|
||||
};
|
||||
|
||||
keyPressedIndex = -1;
|
||||
}
|
||||
|
||||
private void createAndShowGUI() {
|
||||
frame = new Frame("Function Key Keycodes");
|
||||
textArea = new TextArea();
|
||||
textArea.setFocusable(true);
|
||||
frame.add(textArea);
|
||||
frame.pack();
|
||||
frame.setSize(200, 200);
|
||||
|
||||
textArea.addKeyListener(keyListener = new KeyListener() {
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent ke) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent ke) {
|
||||
if (allKeyArr[keyPressedIndex] != ke.getKeyCode()) {
|
||||
throw new RuntimeException("Wrong keycode received");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent ke) {
|
||||
}
|
||||
});
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void removeListener() {
|
||||
if (keyListener != null) {
|
||||
textArea.removeKeyListener(keyListener);
|
||||
keyListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (null != frame) {
|
||||
frame.dispose();
|
||||
frame = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void generateFunctionKeyPress() {
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i < allKeyArr.length; i++) {
|
||||
keyPressedIndex = i;
|
||||
robot.keyPress(allKeyArr[i]);
|
||||
robot.keyRelease(allKeyArr[i]);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
removeListener();
|
||||
|
||||
} catch (AWTException e) {
|
||||
throw new RuntimeException("Robot creation failed");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
AllKeyCode allKeyObj = new AllKeyCode();
|
||||
allKeyObj.createAndShowGUI();
|
||||
allKeyObj.generateFunctionKeyPress();
|
||||
allKeyObj.dispose();
|
||||
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user