Block keyboard and mouse events before the context is initialized.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@23 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package com.threerings.jme;
|
package com.threerings.jme;
|
||||||
|
|
||||||
|
import java.awt.AWTEvent;
|
||||||
import java.awt.Canvas;
|
import java.awt.Canvas;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
@@ -112,7 +113,12 @@ public class JmeCanvasApp extends JmeApp
|
|||||||
{
|
{
|
||||||
// LWJGL's canvas releases the context after painting. we make it
|
// LWJGL's canvas releases the context after painting. we make it
|
||||||
// current again, because we want it valid when we process events.
|
// current again, because we want it valid when we process events.
|
||||||
|
// block mouse and keyboard events until the context is valid.
|
||||||
return new LWJGLCanvas() {
|
return new LWJGLCanvas() {
|
||||||
|
public void addNotify () {
|
||||||
|
super.addNotify();
|
||||||
|
disableEvents(MOUSE_KEY_EVENT_MASK);
|
||||||
|
}
|
||||||
public void update (Graphics g) {
|
public void update (Graphics g) {
|
||||||
super.update(g);
|
super.update(g);
|
||||||
try {
|
try {
|
||||||
@@ -122,6 +128,10 @@ public class JmeCanvasApp extends JmeApp
|
|||||||
e + "].");
|
e + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected void initGL () {
|
||||||
|
super.initGL();
|
||||||
|
enableEvents(MOUSE_KEY_EVENT_MASK);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,4 +191,10 @@ public class JmeCanvasApp extends JmeApp
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected Canvas _canvas;
|
protected Canvas _canvas;
|
||||||
|
|
||||||
|
protected static final long MOUSE_KEY_EVENT_MASK =
|
||||||
|
AWTEvent.MOUSE_EVENT_MASK |
|
||||||
|
AWTEvent.MOUSE_MOTION_EVENT_MASK |
|
||||||
|
AWTEvent.MOUSE_WHEEL_EVENT_MASK |
|
||||||
|
AWTEvent.KEY_EVENT_MASK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user