Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » keyPressed event lacks propper stateMask on first event?
keyPressed event lacks propper stateMask on first event? [message #1007508] Wed, 06 February 2013 04:00 Go to next message
Markus Duft is currently offline Markus Duft
Messages: 95
Registered: February 2013
Member
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 10:23 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1794
Registered: July 2009
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/
Re: keyPressed event lacks propper stateMask on first event? [message #1007690 is a reply to message #1007588] Thu, 07 February 2013 01:59 Go to previous message
Markus Duft is currently offline Markus Duft
Messages: 95
Registered: February 2013
Member
strange... i'm using chrome 18.0.1025.142 on RAP 2.0.0RC1. i actually had no time to come up with a more minimal example as i didn't expect side-effects from our application... maybe this is the problem...

Thanks for helping!
Previous Topic:SWT Resources RAP
Next Topic:RAP Tycho build Bug
Goto Forum:
  


Current Time: Fri Aug 29 01:39:18 EDT 2014

Powered by FUDForum. Page generated in 0.02397 seconds