我在检测文本字段中按下的键时遇到一些问题。
那是我的课文,然后我还有两个按钮:
text1 = new Text(shell, SWT.BORDER | SWT.NO_SCROLL | SWT.SINGLE);
text1.addListener(SWT.KeyUp, new Listener() {
public void handleEvent(Event e) {
e.doit = false;
int i = e.stateMask + e.keyCode;
text1.setText(Integer.toString(i));
}
});
okayButton = new Button(shell, SWT.PUSH);
okayButton.setText("&OK");
cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("&Abbrechen");
我的问题是全局键似乎是在我自己的处理程序之前处理的。 例如,如果我按下Alt + O,则会触发“确定”按钮,但不会触发我的处理程序。按下逃跑的效果相同。
如何阻止执行全局快捷方式并仅执行我自己的handleEvent方法?