Skip to main content


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 09:00 Go to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior 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 15:23 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
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/
Re: keyPressed event lacks propper stateMask on first event? [message #1007690 is a reply to message #1007588] Thu, 07 February 2013 06:59 Go to previous message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior 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:RAP browser scrolling
Next Topic:UrlLauncher can't handle dataURIs
Goto Forum:
  


Current Time: Fri Apr 26 22:10:30 GMT 2024

Powered by FUDForum. Page generated in 0.02845 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top