Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I recommend you didn't use your own custom <code>Keys</code> class, unless your fields point to the SWT-specific key variables. (e.g. <code>Keys.ENTER = SWT.TRAVERSE_RETURN</code>).</p> <p>As you can see from the <a href="http://sscce.org/" rel="nofollow">SSCCE</a> below, the <code>TraverseListener</code> gets notified first. You may cancel your events there.</p> <pre><code>/** * * @author ggrec * */ public class KeyTest { // ==================== 3. Static Methods ============================= public static void main(final String[] args) { new KeyTest(); } // ==================== 4. Constructors =============================== private KeyTest() { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); createContents(shell); shell.pack(); shell.open(); while (!shell.isDisposed()) { if ( !display.readAndDispatch() ) display.sleep(); } display.dispose(); } // ==================== 5. Creators =================================== private static void createContents(final Composite parent) { final Text text = new Text(parent, SWT.NONE); text.addTraverseListener(new TraverseListener() { @Override public void keyTraversed(final TraverseEvent e) { System.out.println("Traversed!"); } }); text.addKeyListener(new KeyListener() { @Override public void keyReleased(final KeyEvent e) { System.out.println("Key released."); } @Override public void keyPressed(final KeyEvent e) { System.out.println("Key pressed."); } }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload