Hi there !
short story :
I experience some problems using GLCanvas with French keyboard when pressing keys like “é” or “à” : the “pressed” event do not happen. ???
full story :
In my example, I made a class called MyListener.
In the “public static void main”, I build a frame with a glcanvas inside it.
I set MyListener as the keylistener of the frame and the canvas.
After that, when I press my “é”, “è”, “ç” or “à” key,
if the frame has the focus (at application start for example), then the pressed, types and released events happen,
but if the canvas has the focus (by clicking on it), then only the type and released events happen.
Here is the minimal code to reproduce my problem (maybe you will need a french keyboard…)
import java.awt.*;
import java.awt.event.*;
import javax.media.opengl.*;
import com.sun.opengl.util.*;
public class MyListener implements
KeyListener, GLEventListener
{
public static void main(String[] args)
{
Frame frame = new Frame();
GLCanvas canvas = new GLCanvas();
MyListener mylistener = new MyListener();
final Animator animator = new Animator(canvas);
frame.add(canvas);
frame.setSize(640, 480);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
new Thread(new Runnable()
{
public void run()
{
animator.stop();
System.exit(0);
}
}
).start();
}
}
);
frame.setVisible(true);
frame.addKeyListener(mylistener);
animator.setRunAsFastAsPossible(false);
animator.start();
canvas.addGLEventListener(mylistener);
canvas.addKeyListener(mylistener);
}
// constructor
public MyListener() {}
// key listener functions
public void keyReleased(KeyEvent e) { System.out.println(e.toString()); }
public void keyPressed(KeyEvent e) { System.out.println(e.toString()); }
public void keyTyped(KeyEvent e) { System.out.println(e.toString()); }
public void init(GLAutoDrawable drawable)
{
GL gl = drawable.getGL();
System.err.println("INIT GL IS: " + gl.getClass().getName());
}
public void reshape(GLAutoDrawable drawable, int x, int y, int _width, int _height)
{
GL gl = drawable.getGL();
System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
}
public void display(GLAutoDrawable drawable) {}
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
}
Is this a bug from GLCanvas ? or maybe I made a mistake … :-\