我在Windows 10(英语和俄语)上有两种语言。我运行下面的代码片段:SWT错误地检测到组合键
public static void main(String[] args) throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(640, 480);
shell.setLocation(500, 250);
shell.setText("SWT");
FillLayout layout = new FillLayout();
shell.setLayout(layout);
shell.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
List<String> keys = new ArrayList<>();
if ((e.stateMask & SWT.CTRL) != 0) {
keys.add("Ctrl");
}
if ((e.stateMask & SWT.ALT) != 0) {
keys.add("Alt");
}
if ((e.stateMask & SWT.SHIFT) != 0) {
keys.add("Shift");
}
keys.add(Character.toString((char) e.keyCode));
System.out.println(keys);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
当语言设置为英文,我按Right Alt + T
,程序正确打印[Alt, t]
。
但是,当我将语言切换为俄语并按Right Alt+T
时,程序将打印[Ctrl, Alt, t]
。这是不正确的,因为我没有按Ctrl。
这很烦人,因为我们的Eclipse RCP密钥绑定(如Alt+F7
或Alt+Shift+F5
)无法正常工作。
SWT错误地检测到的任何想法Ctrl
?
我使用最新的Eclipse 4.6(SWT 3.105.0)中的SWT。
你检查过https://www.eclipse.org/swt/bugs.php吗? – zapl
你确定你没有使用'AltGr'按钮(右'Alt')而不是标准的'Alt'按钮(左'Alt')吗?看起来'AltGr'的解释与键盘布局紧密相关。 –
@LorisSecuro是的,我正在使用右Alt – ZhekaKozlov