SWT Cross-Platform Enter Detection

被刻印的时光 ゝ 提交于 2019-11-27 07:46:06

问题


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?

Thanks.


回答1:


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 
}


来源:https://stackoverflow.com/questions/1688266/swt-cross-platform-enter-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!