keyPressed event lacks propper stateMask on first event? [message #1007508] |
Wed, 06 February 2013 09:00 |
|
Hey!
I have a slight problem detecting whether ctrl is pressed in a key event. i hook this on a Text:
@Override
public void keyPressed(KeyEvent e) {
System.out.println("key: " + e.keyCode + ", " + e.stateMask);
// get the current date and apply to the field
if (e.stateMask == SWT.CTRL && e.keyCode == SWT.ARROW_RIGHT) {
System.out.println("yeah!");
}
}
when i run this and press ctrl+right arrow i'd expect to get "yeah!". however i get this:
key: 262144, 0
key: 16777220, 0
seems the ctrl state is missing from the statemask, even though the ctrl press was recognized. as rap sends a keyup for all keys immediately (it does, right?) i get a keyup for ctrl immediately, thus i also cannot remember the state myself.
interesting thing is, that keeping ctrl pressed and pressing right arrow a second time yields this:
key: 262144, 0
key: 16777220, 0
key: 16777220, 262144
any insights? thanks in advance!
Markus
|
|
|
Re: keyPressed event lacks propper stateMask on first event? [message #1007588 is a reply to message #1007508] |
Wed, 06 February 2013 15:23 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Markus,
just checked your snippet with Controls Demo -> Text Tab and RAP 2.0 in
Firefox, Cherome and IE9 and the state mask is set correctly. Which RAP
version and browser are you using?
Best,
Ivan
On 2/6/2013 3:53 PM, Markus Duft wrote:
> Hey!
>
> I have a slight problem detecting whether ctrl is pressed in a key
> event. i hook this on a Text:
>
>
> @Override
> public void keyPressed(KeyEvent e) {
> System.out.println("key: " + e.keyCode + ", " + e.stateMask);
> // get the current date and apply to the field
> if (e.stateMask == SWT.CTRL && e.keyCode == SWT.ARROW_RIGHT) {
> System.out.println("yeah!");
> }
> }
>
>
> when i run this and press ctrl+right arrow i'd expect to get "yeah!".
> however i get this:
>
>
> key: 262144, 0
> key: 16777220, 0
>
>
> seems the ctrl state is missing from the statemask, even though the
> ctrl press was recognized. as rap sends a keyup for all keys
> immediately (it does, right?) i get a keyup for ctrl immediately, thus
> i also cannot remember the state myself.
>
> interesting thing is, that keeping ctrl pressed and pressing right
> arrow a second time yields this:
>
>
> key: 262144, 0
> key: 16777220, 0
> key: 16777220, 262144
>
>
> any insights? thanks in advance!
>
> Markus
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04711 seconds