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

Bug 366788

Summary: KeyEvent management differs depending browser(retun key keyEvent not sent on ie, safari and chrome)
Product: [RT] RAP Reporter: bertram <bveli75>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: 1.4   
Target Milestone: 1.5 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 367871    
Bug Blocks:    

Description bertram CLA 2011-12-15 04:04:47 EST
I've got a login dialog with a composite containing :
- a button for connection
- a group with
- a text login
- a text password
- a check buton for administrator

with the tab navigation when i focus the check button, and with the space button i can can change the selection of the check button. without focusing the connection button, i want to select the connection button when hitting the return key.

so waht i do was : add a keylistener on the check button, and if the keycode is equal to SWT.CR, i send a selection Event on the connection button.

This works on FF and opera, but not in IE , Safari and Chrome :
- on FF an OPERA : the KeyEvent is sent from client to server (request parameter)
- on IE , Safari and Chrome : No keyEvent sent from client


Note : when hitting alpha numeric caracters, the keyEvent is sent for all browsers.
Comment 1 Tim Buschtoens CLA 2011-12-15 04:48:14 EST
If i what right, what you could use it shell.setDefaultButton. It sets the button that gets selected when Enter is pressed.

I'm looking into why the Enter button isn't sent anyway.
Comment 2 bertram CLA 2011-12-15 05:25:32 EST
Even setting the defaultButton on the shell does not work : (focus is present on the chexk button)
Comment 3 Tim Buschtoens CLA 2011-12-15 07:14:08 EST
Sorry for the butchered comment#1.

I think whats happening is that some widgets call preventDefault internally on certain keydown events (in this case button on Space and Enter), which prevents the keypress event the KeyEventUtil listens to from beeing fired. I would have to check in SWT to be certain, but i think the issue here is that KeyEventUtil only listens for keypress, when it should listen for both (keypress and keydown). I will investigate that possibility.
Comment 4 Tim Buschtoens CLA 2012-01-05 06:04:16 EST
Turns out preventing default for keydown does not supress the follow-up keypress events, so the problem is another.
Comment 5 Tim Buschtoens CLA 2012-01-12 08:24:07 EST
I revoke my precious comment, preventDefault is the problem.

One workaround is to add the button you want to listen to the widgets cancel keys (see RWT.CANCEL_KEYS). But this will also prevent the check button from beeing selected/unselected by the enter key.
Comment 6 Tim Buschtoens CLA 2012-01-12 10:36:26 EST
Partially fixed in CVS HEAD.

Fixed for Combo, Button, ToolItem by removing some unnecessary preventDefault calls. 

For Text this is slightly more complicated, Backspace and Enter might both be necessary to cancel.
Comment 7 Tim Buschtoens CLA 2012-01-18 04:59:29 EST
Fixed together with Bug 367876. Keydown events are now also used to send key events to server.