processKeyEvent method in KeyEventWorkaround class
Submitted by Friday, 18 July, 2008 - 14:18
on
I have some questions for processKeyEvent method in KeyEventWorkaround class.
Q1
case KeyEvent.KEY_PRESSED:
....
default:
if (!evt.isMetaDown()) {
if (evt.isControlDown() && evt.isAltDown()) {
lastKeyTime = 0L;
}
.....
Why lastKeytime = 0 ,when Ctrl and Alt are downed.
Q2
case KeyEvent.KEY_TYPED:
....
if(((modifiers & InputEvent.CTRL_MASK) != 0
^ (modifiers & InputEvent.ALT_MASK) != 0)
|| (modifiers & InputEvent.META_MASK) != 0)
{
return null;
}
Why is it "xor" instead of "or"?
Whren I press Alt and Ctrl and "p key" on Keybord Tester, "CA+p p" is shown in TextField on Linux.
To solve this problem, the following code was compiled.
case KeyEvent.KEY_PRESSED:
....
default:
if (!evt.isMetaDown()) {
if (evt.isControlDown() && evt.isAltDown()) {
//lastKeyTime = 0L;
}
.....
case KeyEvent.KEY_TYPED:
....
if(((modifiers & InputEvent.CTRL_MASK) != 0
|| (modifiers & InputEvent.ALT_MASK) != 0)
|| (modifiers & InputEvent.META_MASK) != 0)
{
return null;
}
Does this code have the problem?
Q1
case KeyEvent.KEY_PRESSED:
....
default:
if (!evt.isMetaDown()) {
if (evt.isControlDown() && evt.isAltDown()) {
lastKeyTime = 0L;
}
.....
Why lastKeytime = 0 ,when Ctrl and Alt are downed.
Q2
case KeyEvent.KEY_TYPED:
....
if(((modifiers & InputEvent.CTRL_MASK) != 0
^ (modifiers & InputEvent.ALT_MASK) != 0)
|| (modifiers & InputEvent.META_MASK) != 0)
{
return null;
}
Why is it "xor" instead of "or"?
Whren I press Alt and Ctrl and "p key" on Keybord Tester, "CA+p p" is shown in TextField on Linux.
To solve this problem, the following code was compiled.
case KeyEvent.KEY_PRESSED:
....
default:
if (!evt.isMetaDown()) {
if (evt.isControlDown() && evt.isAltDown()) {
//lastKeyTime = 0L;
}
.....
case KeyEvent.KEY_TYPED:
....
if(((modifiers & InputEvent.CTRL_MASK) != 0
|| (modifiers & InputEvent.ALT_MASK) != 0)
|| (modifiers & InputEvent.META_MASK) != 0)
{
return null;
}
Does this code have the problem?