Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Capture Ctrl+v in Text?
Capture Ctrl+v in Text? [message #436952] Wed, 26 May 2004 16:03 Go to next message
exquisitus is currently offline exquisitusFriend
Messages: 211
Registered: July 2009
Senior Member
Hi,

I'm trying to capture the 'insert' button combination (CTRL+V) within a Text
widget. How can I do this? Where can I find a tutorial on this? It must be
quite a common asked question but I found nothing useful in the list - sorry
if I ask a question already answered before.

Thanx,
exquisitus
Re: Capture Ctrl+v in Text? [message #436977 is a reply to message #436952] Thu, 27 May 2004 12:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cbr.teamlog.com

Try this :
Add a KeyListener to your Text composite and define the keyPressed method as
bellow :
/**
* @see
org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.sw t.events.KeyEven
t)

*/

public final void keyPressed(final KeyEvent e) {

if ((e.stateMask == SWT.CTRL) && (e.keyCode == 'V' || e.keyCode == 'v'))
{

// DO WHAT YOU WANT TO DO : text.paste() for example...

}

}




"exquisitus" <banshee@wudu.de> a
Re: Capture Ctrl+v in Text? [message #437076 is a reply to message #436977] Fri, 28 May 2004 13:44 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Looking for Ctrl+V will make Mac users unhappy (they use Command+V) and
Motif users unhappy (they use Shift+Ins). Do you want SWT.Verify instead?
The code fragment won't work because SWT generates ^V (Unicode 0x16) when
you tpye a control 'v'.

"Takaido" <cbr@teamlog.com> wrote in message
news:c94lqc$cb1$1@eclipse.org...
> Try this :
> Add a KeyListener to your Text composite and define the keyPressed method
as
> bellow :
> /**
> * @see
>
org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.sw t.events.KeyEven
> t)
>
> */
>
> public final void keyPressed(final KeyEvent e) {
>
> if ((e.stateMask == SWT.CTRL) && (e.keyCode == 'V' || e.keyCode ==
'v'))
> {
>
> // DO WHAT YOU WANT TO DO : text.paste() for example...
>
> }
>
> }
>
>
>
>
> "exquisitus" <banshee@wudu.de> a
Re: Capture Ctrl+v in Text? [message #437110 is a reply to message #437076] Fri, 28 May 2004 23:14 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
You might want to try SWT.MOD1 instead of SWT.CTRL&nbsp; That'll at least
make the MacOS X people happy.&nbsp; Beyond that, you could use a if ()
statment on SWT.getPlatform().equals("some-platform) to determine the
key combo.<br>
<br>
Daniel<br>
<br>
Steve Northover wrote:
<blockquote cite="midc97fa3$vjs$1@eclipse.org" type="cite">
<pre wrap="">Looking for Ctrl+V will make Mac users unhappy (they use Command+V) and
Motif users unhappy (they use Shift+Ins). Do you want SWT.Verify instead?
The code fragment won't work because SWT generates ^V (Unicode 0x16) when
you tpye a control 'v'.

"Takaido" &lt;<a class="moz-txt-link-abbreviated" href="mailto:cbr@teamlog.com">cbr@teamlog.com</a>&gt; wrote in message
<a class="moz-txt-link-freetext" href="news:c94lqc$cb1$1@eclipse.org">news:c94lqc$cb1$1@eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Try this :
Add a KeyListener to your Text composite and define the keyPressed method
</pre>
</blockquote>
<pre wrap=""><!---->as
</pre>
<blockquote type="cite">
<pre wrap="">bellow :
/**
* @see

</pre>
</blockquote>
<pre wrap=""><!----> org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.sw t.events.KeyEven
</pre>
<blockquote type="cite">
<pre wrap="">t)

*/

public final void keyPressed(final KeyEvent e) {

if ((e.stateMask == SWT.CTRL) &amp;&amp; (e.keyCode == 'V' || e.keyCode ==
</pre>
</blockquote>
<pre wrap=""><!---->'v'))
</pre>
<blockquote type="cite">
<pre wrap="">{

// DO WHAT YOU WANT TO DO : text.paste() for example...

}

}




"exquisitus" &lt;<a class="moz-txt-link-abbreviated" href="mailto:banshee@wudu.de">banshee@wudu.de</a>&gt; a &eacute;crit dans le message de news:
<a class="moz-txt-link-abbreviated" href="mailto:c92et5$n8c$1@eclipse.org">c92et5$n8c$1@eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I'm trying to capture the 'insert' button combination (CTRL+V) within a
</pre>
</blockquote>
<pre wrap="">Text
</pre>
<blockquote type="cite">
<pre wrap="">widget. How can I do this? Where can I find a tutorial on this? It must
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->be
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">quite a common asked question but I found nothing useful in the list -
</pre>
</blockquote>
<pre wrap="">sorry
</pre>
<blockquote type="cite">
<pre wrap="">if I ask a question already answered before.

Thanx,
exquisitus


</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
</body>
</html>
Re: Capture Ctrl+v in Text? [message #437180 is a reply to message #437110] Mon, 31 May 2004 14:15 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C446F8.406A0460
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

The SWT.MOD1 won't help the Shift+Ins case. If you can use the =
SWT.Verify event, it hides these details. It sounds to me like you want =
to implement paste (not sure why because the Text control does this =
already for you using the right keys) and this will require you to know =
the key sequence for the platform.

"Daniel Spiewak" <djspiewak@hotpop.com> wrote in message =
news:c98gpp$d00$4@eclipse.org...
You might want to try SWT.MOD1 instead of SWT.CTRL That'll at least =
make the MacOS X people happy. Beyond that, you could use a if () =
statment on SWT.getPlatform().equals("some-platform) to determine the =
key combo.

Daniel

Steve Northover wrote:=20
Looking for Ctrl+V will make Mac users unhappy (they use Command+V) and
Motif users unhappy (they use Shift+Ins). Do you want SWT.Verify =
instead?
The code fragment won't work because SWT generates ^V (Unicode 0x16) =
when
you tpye a control 'v'.

"Takaido" <cbr@teamlog.com> wrote in message
news:c94lqc$cb1$1@eclipse.org...
Try this :
Add a KeyListener to your Text composite and define the keyPressed =
method
as
bellow :
/**
* @see

=
org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.sw t.events.KeyE=
ven
t)

*/

public final void keyPressed(final KeyEvent e) {

if ((e.stateMask =3D=3D SWT.CTRL) && (e.keyCode =3D=3D 'V' || =
e.keyCode =3D=3D
'v'))
{

// DO WHAT YOU WANT TO DO : text.paste() for example...

}

}




"exquisitus" <banshee@wudu.de> a =E9crit dans le message de news:
c92et5$n8c$1@eclipse.org...
Hi,

I'm trying to capture the 'insert' button combination (CTRL+V) within a
Text
widget. How can I do this? Where can I find a tutorial on this? It =
must
be
quite a common asked question but I found nothing useful in the list -
sorry
if I ask a question already answered before.

Thanx,
exquisitus


=20


------=_NextPart_000_001C_01C446F8.406A0460
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><TITLE></TITLE>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>The SWT.MOD1 won't help the Shift+Ins =
case.&nbsp;=20
If you can use the SWT.Verify event, it hides these details.&nbsp; It =
sounds to=20
me like you want to implement paste (not sure why because the Text =
control does=20
this already for you using the right keys) and this will require you to =
know the=20
key sequence for the platform.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>"Daniel Spiewak" &lt;<A=20
href=3D"mailto:djspiewak@hotpop.com">djspiewak@hotpop.com</A>&gt; wrote =
in message=20
<A=20
href=3D"news:c98gpp$d00$4@eclipse.org">news:c98gpp$d00$4@eclipse.org</A>.=
...</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">You=20
might want to try SWT.MOD1 instead of SWT.CTRL&nbsp; That'll at least =
make the=20
MacOS X people happy.&nbsp; Beyond that, you could use a if () =
statment on=20
SWT.getPlatform().equals("some-platform) to determine the key=20
combo.<BR><BR>Daniel<BR><BR>Steve Northover wrote:=20
<BLOCKQUOTE cite=3Dmidc97fa3$vjs$1@eclipse.org type=3D"cite"><PRE =
wrap=3D"">Looking for Ctrl+V will make Mac users unhappy (they use =
Command+V) and
Motif users unhappy (they use Shift+Ins). Do you want SWT.Verify =
instead?
The code fragment won't work because SWT generates ^V (Unicode 0x16) =
when
you tpye a control 'v'.

"Takaido" &lt;<A class=3Dmoz-txt-link-abbreviated =
href=3D"mailto:cbr@teamlog.com">cbr@teamlog.com</A>&gt; wrote in message
<A class=3Dmoz-txt-link-freetext =
href=3D"news:c94lqc$cb1$1@eclipse.org">news:c94lqc$cb1$1@eclipse.org</A>.=
...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Try this :
Add a KeyListener to your Text composite and define the keyPressed =
method
</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->as
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">bellow :
/**
* @see

</PRE></BLOCKQUOTE><PRE =
wrap=3D""><!---->org.eclipse.swt.events.KeyListener#keyPressed(org.eclips=
e.swt.events.KeyEven
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">t)

*/

public final void keyPressed(final KeyEvent e) {

if ((e.stateMask =3D=3D SWT.CTRL) &amp;&amp; (e.keyCode =3D=3D 'V' =
|| e.keyCode =3D=3D
</PRE></BLOCKQUOTE><PRE wrap=3D""><!---->'v'))
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">{

// DO WHAT YOU WANT TO DO : text.paste() for example...

}

}




"exquisitus" &lt;<A class=3Dmoz-txt-link-abbreviated =
href=3D"mailto:banshee@wudu.de">banshee@wudu.de</A>&gt; a =E9crit dans =
le message de news:
<A class=3Dmoz-txt-link-abbreviated =
href=3D"mailto:c92et5$n8c$1@eclipse.org">c92et5$n8c$1@eclipse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I'm trying to capture the 'insert' button combination (CTRL+V) within a
</PRE></BLOCKQUOTE><PRE wrap=3D"">Text
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">widget. How can I do =
this? Where can I find a tutorial on this? It must
</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->be
</PRE>
<BLOCKQUOTE type=3D"cite">
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">quite a common asked =
question but I found nothing useful in the list -
</PRE></BLOCKQUOTE><PRE wrap=3D"">sorry
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">if I ask a question =
already answered before.

Thanx,
exquisitus


</PRE></BLOCKQUOTE><PRE wrap=3D""> </PRE></BLOCKQUOTE><PRE =
wrap=3D""><!---->

</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_001C_01C446F8.406A0460--
Previous Topic:Must one run M6 or above to use AWT in Eclipse?
Next Topic:SWT/Swing bug under linux with M9 RC0
Goto Forum:
  


Current Time: Fri Apr 26 15:49:51 GMT 2024

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

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

Back to the top