SWT跨平台输入检测 [英] SWT Cross-Platform Enter Detection
本文介绍了SWT跨平台输入检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在SWT中有一个全局过滤器(Display.addFilter
),我想在其中检测 Enter 键.在Windows中,按Enter会在KeyListener事件的'keyCode'部分生成SWT.CR
.这个假设对所有平台都安全吗,还是应该检查
I have a global filter (Display.addFilter
) in SWT in which I want to detect Enter key. In Windows, pressing Enter generates SWT.CR
in 'keyCode' part of KeyListener event. Is this assumption safe for all platforms, or should I check if
keyCode == SWT.CR || keyCode == SWT.LF?
谢谢.
推荐答案
如果您想在小部件聚焦时用户按下Enter键来捕获事件,请使用TraverseListener
或类型为
If you want to catch the event when the user presses the Enter key while a widget is in focus, use a TraverseListener
or a Listener with type SWT.Traverse
. Then, you check
if (event.detail == SWT.TRAVERSE_RETURN) {
// The user pressed Enter
}
这篇关于SWT跨平台输入检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文