Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Howto parse Keys from keyCode Integer?
|
Re: Howto parse Keys from keyCode Integer? [message #444063 is a reply to message #444038] |
Wed, 06 October 2004 13:16 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi Ben,
The keyCode just indicates the last single key pressed, so the keyCode of Q
== Ctrl+Q == Ctrl+Shift+Q == 113. To find the modifier keys that are
pressed you should look at the stateMask field, which will be an OR'd set of
SWT.CTRL, SWT.SHIFT and SWT.ALT.
Grant
"Benjmain Pasero" <bpasero@rssowl.org> wrote in message
news:cju9fr$94i$1@eclipse.org...
> Hi,
>
> I wonder if its possible to parse the pressed Keys from the keyCode
> Integer value. I am talking of combined keys, like "Ctrl+Shift+C" or
> "Ctrl+C".
>
> Maybe there is a method that takes the Integer as argument and returns an
> array of containing Keys (like Ctrl, Shift, C)?
>
> Thanks,
> Ben
>
|
|
|
Re: Howto parse Keys from keyCode Integer? [message #444074 is a reply to message #444063] |
Wed, 06 October 2004 16:48 |
Benjamin Pasero Messages: 337 Registered: July 2009 |
Senior Member |
|
|
Hi Grant,
I was asking the wrong question.
What I wanted to know, is it possible to get out the pressed
keys from an int value that was created from OR'd keys?
Like:
SWT.CTRL | 'd' = 262244
and
262244 = SWT.CTRL | 'd'
Something like a parse Method which takes the 262244 as paramter
and returns an int[] array containing the keys SWT.CTRL and 'd'.
Thanks,
Ben
> Hi Ben,
> The keyCode just indicates the last single key pressed, so the keyCode of Q
> == Ctrl+Q == Ctrl+Shift+Q == 113. To find the modifier keys that are
> pressed you should look at the stateMask field, which will be an OR'd set of
> SWT.CTRL, SWT.SHIFT and SWT.ALT.
> Grant
> "Benjmain Pasero" <bpasero@rssowl.org> wrote in message
> news:cju9fr$94i$1@eclipse.org...
> > Hi,
> >
> > I wonder if its possible to parse the pressed Keys from the keyCode
> > Integer value. I am talking of combined keys, like "Ctrl+Shift+C" or
> > "Ctrl+C".
> >
> > Maybe there is a method that takes the Integer as argument and returns an
> > array of containing Keys (like Ctrl, Shift, C)?
> >
> > Thanks,
> > Ben
> >
|
|
|
Re: Howto parse Keys from keyCode Integer? [message #444134 is a reply to message #444074] |
Thu, 07 October 2004 13:11 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
A method like this does not exist since this is not how swt represents these
key combinations. However if you wanted to represent key combinations like
this as a single integer you could since SWT.ALT, SWT.SHIFT and SWT.CTRL are
defined as 1<<16, 1<<17 and 1<<18 respectively, and therefore will not
interfere with each other or with a keyCode value when OR'd together.
Grant
"Benjamin Pasero" <bpasero@rssowl.org> wrote in message
news:ck17l6$o56$1@eclipse.org...
> Hi Grant,
>
> I was asking the wrong question.
> What I wanted to know, is it possible to get out the pressed
> keys from an int value that was created from OR'd keys?
>
> Like:
>
> SWT.CTRL | 'd' = 262244
> and
> 262244 = SWT.CTRL | 'd'
>
> Something like a parse Method which takes the 262244 as paramter
> and returns an int[] array containing the keys SWT.CTRL and 'd'.
>
> Thanks,
> Ben
>
> > Hi Ben,
>
> > The keyCode just indicates the last single key pressed, so the keyCode
of Q
> > == Ctrl+Q == Ctrl+Shift+Q == 113. To find the modifier keys that are
> > pressed you should look at the stateMask field, which will be an OR'd
set of
> > SWT.CTRL, SWT.SHIFT and SWT.ALT.
>
> > Grant
>
> > "Benjmain Pasero" <bpasero@rssowl.org> wrote in message
> > news:cju9fr$94i$1@eclipse.org...
> > > Hi,
> > >
> > > I wonder if its possible to parse the pressed Keys from the keyCode
> > > Integer value. I am talking of combined keys, like "Ctrl+Shift+C" or
> > > "Ctrl+C".
> > >
> > > Maybe there is a method that takes the Integer as argument and returns
an
> > > array of containing Keys (like Ctrl, Shift, C)?
> > >
> > > Thanks,
> > > Ben
> > >
>
>
|
|
|
Re: Howto parse Keys from keyCode Integer? [message #444138 is a reply to message #444134] |
Thu, 07 October 2004 14:56 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
I should also point out the SWT.MODIFIER_MASK field, which is an OR'd
collection of all of the modifiers. This is good to make use of to ensure
that none are missed, either as a result of platform differences (like I
forgot about SWT.COMMAND in my previous post <g>), or if more modifiers are
added in the future.
Grant
"Grant Gayed" <grant_gayed@ca.ibm.com> wrote in message
news:ck3f16$hgo$1@eclipse.org...
> A method like this does not exist since this is not how swt represents
these
> key combinations. However if you wanted to represent key combinations
like
> this as a single integer you could since SWT.ALT, SWT.SHIFT and SWT.CTRL
are
> defined as 1<<16, 1<<17 and 1<<18 respectively, and therefore will not
> interfere with each other or with a keyCode value when OR'd together.
>
> Grant
>
> "Benjamin Pasero" <bpasero@rssowl.org> wrote in message
> news:ck17l6$o56$1@eclipse.org...
> > Hi Grant,
> >
> > I was asking the wrong question.
> > What I wanted to know, is it possible to get out the pressed
> > keys from an int value that was created from OR'd keys?
> >
> > Like:
> >
> > SWT.CTRL | 'd' = 262244
> > and
> > 262244 = SWT.CTRL | 'd'
> >
> > Something like a parse Method which takes the 262244 as paramter
> > and returns an int[] array containing the keys SWT.CTRL and 'd'.
> >
> > Thanks,
> > Ben
> >
> > > Hi Ben,
> >
> > > The keyCode just indicates the last single key pressed, so the keyCode
> of Q
> > > == Ctrl+Q == Ctrl+Shift+Q == 113. To find the modifier keys that are
> > > pressed you should look at the stateMask field, which will be an OR'd
> set of
> > > SWT.CTRL, SWT.SHIFT and SWT.ALT.
> >
> > > Grant
> >
> > > "Benjmain Pasero" <bpasero@rssowl.org> wrote in message
> > > news:cju9fr$94i$1@eclipse.org...
> > > > Hi,
> > > >
> > > > I wonder if its possible to parse the pressed Keys from the keyCode
> > > > Integer value. I am talking of combined keys, like "Ctrl+Shift+C" or
> > > > "Ctrl+C".
> > > >
> > > > Maybe there is a method that takes the Integer as argument and
returns
> an
> > > > array of containing Keys (like Ctrl, Shift, C)?
> > > >
> > > > Thanks,
> > > > Ben
> > > >
> >
> >
>
>
|
|
| |
Goto Forum:
Current Time: Wed Sep 25 05:41:46 GMT 2024
Powered by FUDForum. Page generated in 0.04692 seconds
|