Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Howto parse Keys from keyCode Integer?
Howto parse Keys from keyCode Integer? [message #444038] Tue, 05 October 2004 14:01 Go to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
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 #444063 is a reply to message #444038] Wed, 06 October 2004 13:16 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
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 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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
> > > >
> >
> >
>
>
Re: Howto parse Keys from keyCode Integer? [message #444218 is a reply to message #444038] Fri, 08 October 2004 19:42 Go to previous message
Douglas Pollock is currently offline Douglas PollockFriend
Messages: 84
Registered: July 2009
Member
Benjmain Pasero wrote:
> 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)?

You can look at the code from SWTSupport in the "org.eclipse.ui.workbench"
plug-in.



cheers,
d.
Previous Topic:API for getting Tooltip delay?
Next Topic:[ images - text drawing ] rotated text?
Goto Forum:
  


Current Time: Sat Oct 24 18:54:38 GMT 2020

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

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

Back to the top