assertj-swing
assertj-swing copied to clipboard
Invalid key code '47' (German Locale)
Issue by Ludwig Kirchner from Tue, 17 Nov 2009 07:52:44 -0600 Originally opened as http://jira.codehaus.org/browse/FEST-253
Changing the lines
mappings.add(mapping('-', VK_SLASH, NO_MASK));
mappings.add(mapping('_', VK_SLASH, SHIFT_MASK));
to :
mappings.add(mapping('-', 45, NO_MASK));
mappings.add(mapping('_', 45, SHIFT_MASK));
in the class KeyStrokeMappingProvider_de
would resolve the Problem.
votes (original issue): 0 watches (original issue): 0
Comment by ludki from Wed, 18 Nov 2009 02:59:13 -0600
ok, I find out that 45 is the Value of VK_MINUS and that for most of the keys there is no mapping needed.
The following test succeeds:
KeyStrokeMap.clearKeyStrokes(); String str = "!\"§$%&/()=?`´ß0987654321²{[]}\\@qwertzuiopüas" + "dfghjklöäyxcvbnm,.-µ;:_MNBVCXYASDFGHJKLÖÄÜPOIUZTREWQ+*~'#_-:.;,><|"; JTextComponentFixture txt = textBox("myTextBox"); robot.enterText(str); txt.requireText(str);
(str consists all german-keyboard-character)
For the line
robot.enterText("\r");
the mapping
mappings.add(mapping('\r', VK_ENTER, NO_MASK));
is necessary.
Comment by ludki from Wed, 18 Nov 2009 03:17:03 -0600
With folowing modifications
KeyStrokeMap.clearKeyStrokes(); KeyStrokeMap.addKeyStrokesFrom(new KeyStrokeMappingProviderDE()); String str = "!\"§$%&/()=?`´ß0987654321²{[]}\\@qwertzuiopüas" + "dfghjklöäyxcvbnm,.-µ;:_MNBVCXYASDFGHJKLÖÄÜPOIUZTREWQ+*~'#_-:.;,><|"; JTextComponentFixture txt = textBox("myTextBox"); robot.enterText(str); txt.requireText(str);
(KeyStrokeMappingProviderDE is a copy of the latest version of KeyStrokeMappingProvider_de)
the test fails with IllegalArgumentException: Invalid key code '61' after typing the '?'.
Comment by alexruiz from Wed, 18 Nov 2009 07:54:14 -0600
Hi Ludwig,
Many thanks for taking the time to look into this issue in detail!
A couple of days ago I fixed FEST-175, which relates to German keyboard mappings. The latest version is the one: http://fisheye.codehaus.org/browse/fest/fest-swing/src/main/java/org/fest/swing/keystroke/KeyStrokeMappingProvider_de.java?r=HEAD
Can you please give it a try?
Many thanks in advance,
-Alex
Comment by ludki from Fri, 20 Nov 2009 04:47:26 -0600
Hi Alex,
I used that version for the test (I copied the content of KeyStrokeMappingProvider_de in the class KeyStrokeMappingProviderDE).
Comment by alexruiz from Mon, 15 Mar 2010 08:33:57 -0500
Hi Ludwig,
I'm back to trying to fix this bug. I uploaded a new swing-fest jar at our Maven repo: http://snapshots.repository.codehaus.org/org/easytesting . The direct link to the jar is http://snapshots.repository.codehaus.org/org/easytesting/fest-swing/1.2b1-SNAPSHOT/fest-swing-1.2b1-20100315.133020-2.jar
Please give it a try whenever you have a chance and let me know if this bug is fixed
Thanks!
-Alex
Comment by streifi from Mon, 16 Aug 2010 07:32:49 -0500
Hi Alex,
for windows it is necessary to add a separate mapping for german
KeyStrokeMappingProvider_win_de
where you must remove all mappings with ALT_GRAPH_MASK
public class KeyStrokeMappingProvider_win_de extends KeyStrokeMappingProvider_de {
@Override
public Collection<KeyStrokeMapping> keyStrokeMappings() {
Collection<KeyStrokeMapping> mappings = super.keyStrokeMappings();
//remove problematic keys here
mappings.remove(mapping('
', VK_SLASH, ALT_GRAPH_MASK));
mappings.remove(mapping('@', VK_Q, ALT_GRAPH_MASK));
mappings.remove(mapping('Ä', VK_E, ALT_GRAPH_MASK));
mappings.remove(mapping('~', VK_CLOSE_BRACKET, ALT_GRAPH_MASK));
mappings.remove(mapping('|', VK_BACK_SLASH, ALT_GRAPH_MASK));
mappings.remove(mapping(']', VK_9, ALT_GRAPH_MASK));
mappings.remove(mapping('[', VK_8, ALT_GRAPH_MASK));
mappings.remove(mapping('
{', VK_7, ALT_GRAPH_MASK)); mappings.remove(mapping('≥', VK_0, ALT_GRAPH_MASK)); mappings.remove(mapping('≤', VK_2, ALT_GRAPH_MASK)); mappings.remove(mapping('}
', VK_0, ALT_GRAPH_MASK));
return mappings;
}
}
because these are not working with java.lang.Robot on windows os with german keyboard.
On mac os with german keyboard ALT_GRAPH_MASK is working with java.lang.Robot.
Therefore please add KeyStrokeMappingProvider_win_de to the fest-swing release.
Thanks,
Christian