KeyEvent is not KeyEvent
Posted by
Kraft on
Dec 17, 2010; 11:17pm
URL: https://forum.jogamp.org/KeyEvent-is-not-KeyEvent-tp2107883.html
Hi all !
I'm facing some problem with
com.jogamp.newt.event.KeyEvent.
To be more specific,
com.jogamp.newt.event.KeyEvent does not act like
java.awt.event.KeyEvent !
Context :
On 2 sample programs using NEWT and AWT (see code under), using my
french keyboard, i'm trying to type
"î".
On any application (like firefox), with my keyboard, i have to press [^] then [i] in order to print "î".
Experiment :
Using the AWT sample, with a
java.awt.Frame and
java.awt.KeyEvent, the getKeyChar() method of the second keyevent (when pressing [i]) returns "î".
Using the NEWT sample, with a
com.jogamp.newt.opengl.GLWindow and
com.jogamp.newt.event.KeyEvent, the getKeyChar() method of the second keyevent returns "i" (instead of "î").
Am i doing something wrong or it is a limitation of com.jogamp.newt.event.KeyEvent ?I'm using jogl
candidate jars (dated 14 december 2010).
Sample NEWT :package test.keyevent;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
public class NEWTKeyEventDemo implements KeyListener {
public void keyTyped(KeyEvent e) {
System.out.println("[keyTyped] keychar : "+ e.getKeyChar());
}
public void keyPressed(KeyEvent e) {
System.out.println("[keyPressed] keychar : "+ e.getKeyChar());
}
public void keyReleased(KeyEvent e) {
System.out.println("[keyReleased] keychar : "+ e.getKeyChar());
}
public static void main(String[] args) throws InterruptedException {
// create listener
NEWTKeyEventDemo demo = new NEWTKeyEventDemo();
// create and set up the window
GLProfile.initSingleton(false);
GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
GLWindow window = GLWindow.create(caps);
window.setSize(320, 240);
window.setVisible(true);
window.setTitle("BDiDemoWidgets");
window.addWindowListener(new WindowAdapter() {
public void windowDestroyNotify(WindowEvent arg0) {
System.exit(0);
};
});
window.addKeyListener(demo);
while(true)
Thread.sleep(1000);
}
}
Sample AWT :package test.keyevent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
public class AWTKeyEventDemo implements KeyListener {
public void keyTyped(KeyEvent e) {
System.out.println("[keyTyped] keychar : "+ e.getKeyChar());
}
public void keyPressed(KeyEvent e) {
System.out.println("[keyPressed] keychar : "+ e.getKeyChar());
}
public void keyReleased(KeyEvent e) {
System.out.println("[keyReleased] keychar : "+ e.getKeyChar());
}
public static void main(String[] args) {
// create listener
AWTKeyEventDemo demo = new AWTKeyEventDemo();
//Create and set up the window.
JFrame frame = new JFrame("KeyEventDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Display the window.
frame.setSize(320, 240);
frame.setVisible(true);
frame.addKeyListener(demo);
}
}