Home » Eclipse Projects » Standard Widget Toolkit (SWT) » VerifyListener, statemask
|
Re: VerifyListener, statemask [message #514773 is a reply to message #514267] |
Tue, 16 February 2010 10:36 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi Pietro,
I see this too. I don't know if it's intentional or not, since the main
point of the Verify event is to verify whether the text should be inserted.
However since VerifyEvent extends KeyEvent, the KeyDown information probably
could be provided as well. Feel free to log a request for this with SWT at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT&bug_severity=enhancement .
In the meantime, I think the only way to detect a case like this is to
listen in KeyDown, and if Ctrl+V is detected then set some property on the
Text so that it knows that the next received Verify event came from Ctrl+V.
(Keep in mind that Shift+Insert also pastes, and Command+V on OS X).
Grant
"Pietro Santurelli" <santurelli@inwind.it> wrote in message
news:hl5tj0$bjf$1@build.eclipse.org...
> Hi,
> I'm trying to detect when user has pressed CTRL+V to paste text in my
> textbox.
> With KeyListener all do right but when I use VerifyListener statemask is
> always zero.
> I'm on Windows XP and I'm using SWT version 3.448.
> Here is a portion of code:
> public void verifyText(VerifyEvent arg0) {
> arg0.doit = false;
> // System.out.println("carattere: " + arg0.character);
> if (arg0.stateMask == SWT.CTRL && arg0.keyCode == 99)
> {
> System.out.println("CTRL C is pressed");
> }
> else if (arg0.stateMask == SWT.CTRL && arg0.keyCode == 118)
> {
> System.out.println("CTRL V is pressed");
> }
> else
> System.out.println(arg0.stateMask + " *** " + arg0.keyCode);
> }
> }
>
> Is this a bug?
>
> Thanks in advance,
> Pietro
|
|
|
Re: VerifyListener, statemask [message #514873 is a reply to message #514773] |
Tue, 16 February 2010 23:26 |
Pietro Messages: 27 Registered: July 2009 |
Junior Member |
|
|
Hi Grant,
thanks for your response.
I've found that when user enter a key combination (say CTRL+v), the
property keyCode of VerifyEvent is 0.
I can utilize that value to understand that user has entered a key
combination.
Is that rigth?
Thanks,
Pietro
P.S.
Exceuse me for my poor english
Il 16/02/2010 16.20, Grant Gayed ha scritto:
> Hi Pietro,
>
> I see this too. I don't know if it's intentional or not, since the main
> point of the Verify event is to verify whether the text should be inserted.
> However since VerifyEvent extends KeyEvent, the KeyDown information probably
> could be provided as well. Feel free to log a request for this with SWT at
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT&bug_severity=enhancement .
>
> In the meantime, I think the only way to detect a case like this is to
> listen in KeyDown, and if Ctrl+V is detected then set some property on the
> Text so that it knows that the next received Verify event came from Ctrl+V.
> (Keep in mind that Shift+Insert also pastes, and Command+V on OS X).
>
> Grant
>
>
> "Pietro Santurelli"<santurelli@inwind.it> wrote in message
> news:hl5tj0$bjf$1@build.eclipse.org...
>> Hi,
>> I'm trying to detect when user has pressed CTRL+V to paste text in my
>> textbox.
>> With KeyListener all do right but when I use VerifyListener statemask is
>> always zero.
>> I'm on Windows XP and I'm using SWT version 3.448.
>> Here is a portion of code:
>> public void verifyText(VerifyEvent arg0) {
>> arg0.doit = false;
>> // System.out.println("carattere: " + arg0.character);
>> if (arg0.stateMask == SWT.CTRL&& arg0.keyCode == 99)
>> {
>> System.out.println("CTRL C is pressed");
>> }
>> else if (arg0.stateMask == SWT.CTRL&& arg0.keyCode == 118)
>> {
>> System.out.println("CTRL V is pressed");
>> }
>> else
>> System.out.println(arg0.stateMask + " *** " + arg0.keyCode);
>> }
>> }
>>
>> Is this a bug?
>>
>> Thanks in advance,
>> Pietro
>
>
|
|
|
Re: VerifyListener, statemask [message #515082 is a reply to message #514873] |
Wed, 17 February 2010 16:28 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Yes, this approach should mostly work. The only common case I can think of
where this would give a false-positive is Ctrl+Z. Also, it is possible that
some accessibility assistive technologies could give the user a way of
manipulating text without the corresponding keystrokes, which could also
give a false-positive. Whether these cases matter to you or not depends on
why you want to handle the paste-from-clipboard case specially.
Grant
"Pietro Santurelli" <santurelli@inwind.it> wrote in message
news:hlf9nr$4l6$1@build.eclipse.org...
> Hi Grant,
> thanks for your response.
> I've found that when user enter a key combination (say CTRL+v), the
> property keyCode of VerifyEvent is 0.
> I can utilize that value to understand that user has entered a key
> combination.
> Is that rigth?
>
> Thanks,
> Pietro
>
> P.S.
> Exceuse me for my poor english
>
> Il 16/02/2010 16.20, Grant Gayed ha scritto:
> > Hi Pietro,
> >
> > I see this too. I don't know if it's intentional or not, since the main
> > point of the Verify event is to verify whether the text should be
inserted.
> > However since VerifyEvent extends KeyEvent, the KeyDown information
probably
> > could be provided as well. Feel free to log a request for this with SWT
at
> >
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT&bug_severity=enhancement .
> >
> > In the meantime, I think the only way to detect a case like this is to
> > listen in KeyDown, and if Ctrl+V is detected then set some property on
the
> > Text so that it knows that the next received Verify event came from
Ctrl+V.
> > (Keep in mind that Shift+Insert also pastes, and Command+V on OS X).
> >
> > Grant
> >
> >
> > "Pietro Santurelli"<santurelli@inwind.it> wrote in message
> > news:hl5tj0$bjf$1@build.eclipse.org...
> >> Hi,
> >> I'm trying to detect when user has pressed CTRL+V to paste text in my
> >> textbox.
> >> With KeyListener all do right but when I use VerifyListener statemask
is
> >> always zero.
> >> I'm on Windows XP and I'm using SWT version 3.448.
> >> Here is a portion of code:
> >> public void verifyText(VerifyEvent arg0) {
> >> arg0.doit = false;
> >> // System.out.println("carattere: " + arg0.character);
> >> if (arg0.stateMask == SWT.CTRL&& arg0.keyCode == 99)
> >> {
> >> System.out.println("CTRL C is pressed");
> >> }
> >> else if (arg0.stateMask == SWT.CTRL&& arg0.keyCode == 118)
> >> {
> >> System.out.println("CTRL V is pressed");
> >> }
> >> else
> >> System.out.println(arg0.stateMask + " *** " +
arg0.keyCode);
> >> }
> >> }
> >>
> >> Is this a bug?
> >>
> >> Thanks in advance,
> >> Pietro
> >
> >
>
|
|
|
Goto Forum:
Current Time: Sat Dec 14 16:38:56 GMT 2024
Powered by FUDForum. Page generated in 0.03521 seconds
|