English 中文(简体)
SWT Cross-Platform Enter Detection
原标题:

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.

问题回答

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 
}




相关问题
XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

How can I get a volume serial number using wxWidgets?

I m looking for a function/class in wxWidgets which can give me a volume serial number (like win32 GetVolumeInformation function does). I assume that the volume serial number must be pretty much ...

Creating & Editing MS-Word documents on a linux server?

Looking to develop server-side application that will process documents. The source documents are mostly MS-Word 2003, 2007, i.e. the MS version of Docx. Want the server application to be able to run ...

Compiling windows binaries from Ubuntu?

I am doing a cross-platform C (not ++) game with both linux (main) and windows (alternate) binaries. Until now I used devcpp to compile in windows, but I have trouble getting some libraries to work ...

SWT Cross-Platform Enter Detection

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 ...

Python app distribution cross-platform

I want to distribute my app on OSX (using py2app) and as a Debian package. The structure of my app is like: app/ debian/ <lots of debian related stuff> scripts/ ...

热门标签