Community
Participate
Working Groups
Build ID: M20090211-1700 Steps To Reproduce: Trying to send a special character that require the Alt Gr key or a dead key is not possible. More information: I'm using Display.post() to send native key event so I can test my plugin application. However, I am unable to type any special characters that require the AltGr key. If I want to type "@" the following key should be pressed using Display.post (with a Canadian French keyboard): AltGr+2. Display.post() simply doesn't permit sending the AltGr key and there is no constant for that key in SWT. I have also tried to send the '@' character directly, but Display.post() translate it to a '2' before sending the event... The AltGr key is equivalent to Ctrl+Alt on Windows platform, but that is not the case on Linux and I have no idea about Mac and therefore SWT should have a keycode for sending it with Display.post() Event event = new Event(); event.type = SWT.KeyDown; event.keyCode = 0; event.character='@'; Assert.isTrue(display.post(event)); event = new Event(); event.type = SWT.KeyUp; event.keyCode = 0; event.character='@'; Assert.isTrue(display.post(event)); // Result is 2 since the AltGr can't be sent Moreover, if I want to use a dead key to type an accented character (ê for example), I normally would have to send these events: ^ e . Display.post() fail to send the ^ character because it doesn't understand it; OS.XKeysymToKeycode (xDisplay, keysym) (Display line 2924) returns 0 when keysym = '^' (234). However, if I try to send the characters "[e" through Display.post(), the resulting character is ê, because Display.post() translate the [ into a ^ with OS.XKeysymToKeycode (xDisplay, keysym) when keysym = '[' (91) before sending the event (this happens because the '[' character is typed using AltGr+^)! Event event = new Event(); event.type = SWT.KeyDown; event.keyCode = 0; event.character='['; Assert.isTrue(display.post(event)); event = new Event(); event.type = SWT.KeyUp; event.keyCode = 0; event.character='['; Assert.isTrue(display.post(event)); event = new Event(); event.type = SWT.KeyDown; event.keyCode = 0; event.character='e'; Assert.isTrue(display.post(event)); event = new Event(); event.type = SWT.KeyUp; event.keyCode = 0; event.character='e'; Assert.isTrue(display.post(event)); // Result is ê In case this might help, I'm running Eclipse 3.4.2 on Linux/gtk/x86 with jdk 1.6.0_13
When you recieve an AltGr key event, what is the keycode? (I don't have a keyboard to test this)
I managed to get my hands on a sun-type-5 keyboard (http://www.sunstuff.org/hardware/components/keyboards/sun.type5-keyboard.jpg) changing the keyboard layout on the mac to Canadian French (System Preferences>International>Input Menu) The Keycode I get is the same as that of alt, but then again, I'm on a mac and alt-gr seems to fold into alt. Apparently even AWT robot does not make life simple -- keycodes are different on different layouts, so this is going to be a tough one to crack :(
The right alt key act as the AltGr on any keyboard: you only have to change the native keyboard layout. On linux, the command to change the native keyboard layout is setxkbmap (keyboard). For example, setxkbmap ca would set the keyboard layout to a French Canadian (http://en.wikipedia.org/wiki/Keyboard_layout#Canadian_French). On windows, the language bar permits you to add native keyboard support or you can go do that in the control panel -> regional and language (http://www.conversationexchange.com/resources/keyboard-language.php) If I press AltGr+2 on my keyboard, what I receive in SWT is this: KeyDown [1]: KeyEvent{StyledText {} time=349008405 data=null character='@' keyCode=50 stateMask=0 doit=true} KeyUp [2]: KeyEvent{StyledText {} time=349008453 data=null character='@' keyCode=50 stateMask=0 doit=true} If I type 2, I get the exact same keycode and stateMask, but the character is different: KeyDown [1]: KeyEvent{StyledText {} time=349056757 data=null character='2' keyCode=50 stateMask=0 doit=true} KeyUp [2]: KeyEvent{StyledText {} time=349056837 data=null character='2' keyCode=50 stateMask=0 doit=true} On Linux Ubuntu, when I press the AltGr key it recognize it as ISO Level3 Shift > Apparently even AWT robot does not make life simple -- keycodes are different on different layouts When I did some tests on Windows, I couldn't send AltGr through that Robot, I had to send Ctrl+Alt myself. On Linux, I can send AltGr with it, but when I send another key it doesn't see it as pressed, so it's not working either.
*** This bug has been marked as a duplicate of bug 302171 ***