From 5f87f820c98c7b7370838981d3c88230f0e8451e Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Sun, 13 Nov 2011 22:50:24 +0000 Subject: [PATCH] - enable input workaround for canvas git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8665 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../sceneviewer/SceneViewerTopComponent.java | 106 +++++++++--------- 1 file changed, 55 insertions(+), 51 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java index a874ab0b4..3871eaea8 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java @@ -24,6 +24,7 @@ */ package com.jme3.gde.core.sceneviewer; +import com.jme3.gde.core.Installer; import com.jme3.gde.core.filters.FilterExplorerTopComponent; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.scene.SceneRequest; @@ -48,6 +49,7 @@ import org.openide.awt.UndoRedo; import org.openide.util.Exceptions; import org.openide.util.HelpCtx; import org.openide.util.Lookup; +import org.openide.util.NbPreferences; /** * Top component which displays something. @@ -90,57 +92,59 @@ public final class SceneViewerTopComponent extends TopComponent { //We add a mouse wheel listener to the top conmponent in order to correctly dispatch the event ot the cam controller //the oGLPanel may naver have the focus. -// addMouseWheelListener(new MouseWheelListener() { -// -// public void mouseWheelMoved(final MouseWheelEvent e) { -// SceneApplication.getApplication().enqueue(new Callable() { -// -// public Void call() throws Exception { -// String action = "MouseWheel-"; -// if (e.getWheelRotation() < 0) { -// action = "MouseWheel"; -// } -// app.getActiveCameraController().onAnalog(action, e.getWheelRotation(), 0); -// return null; -// } -// }); -// } -// }); -// addKeyListener(new KeyListener() { -// -// public void keyTyped(KeyEvent evt) { -// } -// -// public void keyPressed(final KeyEvent evt) { -// SceneApplication.getApplication().enqueue(new Callable() { -// -// public Void call() throws Exception { -// int code = AwtKeyInput.convertAwtKey(evt.getKeyCode()); -// KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, false); -// keyEvent.setTime(evt.getWhen()); -// if (app.getActiveCameraController() != null) { -// app.getActiveCameraController().onKeyEvent(keyEvent); -// } -// return null; -// } -// }); -// } -// -// public void keyReleased(final KeyEvent evt) { -// SceneApplication.getApplication().enqueue(new Callable() { -// -// public Void call() throws Exception { -// int code = AwtKeyInput.convertAwtKey(evt.getKeyCode()); -// KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, false); -// keyEvent.setTime(evt.getWhen()); -// if (app.getActiveCameraController() != null) { -// app.getActiveCameraController().onKeyEvent(keyEvent); -// } -// return null; -// } -// }); -// } -// }); + if ("true".equals(NbPreferences.forModule(Installer.class).get("use_lwjgl_canvas", "false"))) { + addMouseWheelListener(new MouseWheelListener() { + + public void mouseWheelMoved(final MouseWheelEvent e) { + SceneApplication.getApplication().enqueue(new Callable() { + + public Void call() throws Exception { + String action = "MouseWheel-"; + if (e.getWheelRotation() < 0) { + action = "MouseWheel"; + } + app.getActiveCameraController().onAnalog(action, e.getWheelRotation(), 0); + return null; + } + }); + } + }); + addKeyListener(new KeyListener() { + + public void keyTyped(KeyEvent evt) { + } + + public void keyPressed(final KeyEvent evt) { + SceneApplication.getApplication().enqueue(new Callable() { + + public Void call() throws Exception { + int code = AwtKeyInput.convertAwtKey(evt.getKeyCode()); + KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, false); + keyEvent.setTime(evt.getWhen()); + if (app.getActiveCameraController() != null) { + app.getActiveCameraController().onKeyEvent(keyEvent); + } + return null; + } + }); + } + + public void keyReleased(final KeyEvent evt) { + SceneApplication.getApplication().enqueue(new Callable() { + + public Void call() throws Exception { + int code = AwtKeyInput.convertAwtKey(evt.getKeyCode()); + KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, false); + keyEvent.setTime(evt.getWhen()); + if (app.getActiveCameraController() != null) { + app.getActiveCameraController().onKeyEvent(keyEvent); + } + return null; + } + }); + } + }); + } }