Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334504

Summary: Traverse event with detail = TRAVERSE_RETURN not fired in IE, Safari and Chrome
Product: [RT] RAP Reporter: Ivan Furnadjiev <ivan>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: 1.4   
Target Milestone: 1.4 M5   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 329926    

Description Ivan Furnadjiev CLA 2011-01-17 04:52:01 EST
When you press ENTER key on a control, TraverseEvent with detail = TRAVERSE_RETURN should be fired. This works in Firefox, but not in the browsers that use sync key events (IE, Safari, Chrome and Opera). The reason for it is that for these browsers the keyCode filed send from the browser is 0, but charCode is 13. In FF keyCode = 13, charCode=0. Thus, ControlLCAUtil#processKeyEvents determine the traverseKey as SWT.TRAVERSE_NONE, as it is taken from keyCode field only. As a result no TraverseEvent is fired.
Snippet:
    Text text = new Text( parent, SWT.SINGLE | SWT.BORDER );
    text.addKeyListener( new KeyListener() {
      public void keyPressed( final KeyEvent e ) {
        System.out.println( "keyPressed:" + e );
      }
      public void keyReleased( final KeyEvent e ) {
        System.out.println( "keyReleased:" + e );
      }
    } );
    text.addTraverseListener( new TraverseListener() {
      public void keyTraversed( TraverseEvent e ) {
        System.out.println( "keyTraversed:" + e );
      }

    } );
To reproduce, press ENTER key in the text filed. KeyEvents are fired, but not the TraverseEvent.  Works fine in Firefox.
This functionality is needed to prevent the default button in the cell editors - see bug 329926.
Comment 1 Tim Buschtoens CLA 2011-01-18 08:17:23 EST
Fixed in CVS HEAD by updating EventHandlerUtil#getKeyCode and getCharCode