CTRL+C, CTRL+V, CTRL+X in JFace dialogs [message #447893] |
Tue, 21 December 2004 14:15 |
Stefan Junsved Messages: 56 Registered: July 2009 |
Member |
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_00FA_01C4E76F.E2DBD3A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all,
I have read almost every mail about how to work with key events but I =
still cannot get the hang of it.
I use A LOT of JFace dialogs with tree viewers over a GEF editor, and =
I'm desperatly trying to make
ctrl+c, ctrl+v, and ctrl+x to work.
I have done the following:
1. In the dialog constructor I have invoked:
parentShell.getDisplay().addFilter(SWT.KeyDown, new Listener() =
{
public void handleEvent(Event event) {
if( (event.keyCode =3D=3D 'c') && (event.stateMask =
=3D=3D SWT.CTRL) ) {
=
System.out.println("YES!!!!!=3D"+event.keyCode+"\nSTATE =
MASK=3D"+event.stateMask);
}
}});
This doesn't work as planned because when pressing the CTRL key, =
and still keeping it pressed down, the
CTRL event is caught, but the following 'C', 'V', or 'X' event =
is not.
2. I have added a KeyListener to the tree viewer in the dialog:
treeViewer.getControl().addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent event) {
if( (event.keyCode =3D=3D 'c') && (event.stateMask =
=3D=3D SWT.CTRL) ) {
=
System.out.println("YES!!!!!=3D"+event.keyCode+"\nSTATE =
MASK=3D"+event.stateMask);
}
System.out.println("KEY=3D"+event.keyCode+"\nSTATE =
MASK=3D"+event.stateMask);
}
public void keyReleased(KeyEvent event) {
//System.out.println("KEY=3D"+event.keyCode+"\nSTATE =
MASK=3D"+event.stateMask);
}});
The result is exactly the same as in the earlier example.
Of course I=B4m missing something very central here and I would very =
much appreciate some help on this issue.
------=_NextPart_000_00FA_01C4E76F.E2DBD3A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2523" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have read almost every mail about how =
to work=20
with key events but I still cannot get the hang of it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I use A LOT of JFace dialogs with tree =
viewers over=20
a GEF editor, and I'm desperatly trying to make</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>ctrl+c, ctrl+v, and ctrl+x to =
work.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have done the following:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>1. In the dialog =
constructor I=20
have invoked:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
parentShell.getDisplay().addFilter(SWT.KeyDown, new Listener()=20
{<BR> =
=20
public void handleEvent(Event event)=20
{<BR> &n=
bsp; =20
if( (event.keyCode =3D=3D 'c') && =
(event.stateMask =3D=3D=20
SWT.CTRL) )=20
{<BR> &n=
bsp; &n bsp; =20
=
System.out.println("YES!!!!!=3D"+event.keyCode+"\nSTATE=20
MASK=3D"+event.stateMask);<BR> &=
nbsp; & nbsp; =20
}<BR> &n=
bsp; =20
}});</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> This=20
doesn't work as planned because when pressing the CTRL key, and still =
keeping it=20
pressed down, the</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
CTRL event is=20
caught, but the following 'C', 'V', or 'X' event is not.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>2. I have added a =
KeyListener to=20
the tree viewer in the dialog:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
treeViewer.getControl().addKeyListener(n ew KeyListener()=20
{<BR> =
public=20
void keyPressed(KeyEvent event)=20
{<BR> &n=
bsp; =20
if( (event.keyCode =3D=3D 'c') && (event.stateMask =3D=3D =
SWT.CTRL) )=20
{<BR> &n=
bsp; &n bsp; =20
System.out.println("YES!!!!!=3D"+event.keyCode+"\nSTATE=20
MASK=3D"+event.stateMask);<BR> &=
nbsp; & nbsp; =20
}<BR> &n=
bsp; =20
System.out.println("KEY=3D"+event.keyCode+"\nSTATE=20
MASK=3D"+event.stateMask);<BR> &=
nbsp; =20
}<BR> =
public=20
void keyReleased(KeyEvent event)=20
{<BR> &n=
bsp; =20
//System.out.println("KEY=3D"+event.keyCode+"\nSTATE=20
MASK=3D"+event.stateMask);<BR> &=
nbsp; =20
}});<BR> The result is exactly the =
same as=20
in the earlier example.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Of course I=B4m missing something very =
central here=20
and I would very much appreciate some help on this=20
issue.</FONT></DIV></BODY></HTML>
------=_NextPart_000_00FA_01C4E76F.E2DBD3A0--
|
|
|
Powered by
FUDForum. Page generated in 0.02775 seconds