SDK :
- Fixed focus issue in the sdk (part 1) git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9607 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
3f8d7f0807
commit
737b765cb0
@ -27,6 +27,7 @@ package com.jme3.gde.core.scene.controller;
|
|||||||
import com.jme3.app.Application;
|
import com.jme3.app.Application;
|
||||||
import com.jme3.app.state.AbstractAppState;
|
import com.jme3.app.state.AbstractAppState;
|
||||||
import com.jme3.app.state.AppStateManager;
|
import com.jme3.app.state.AppStateManager;
|
||||||
|
import com.jme3.gde.core.Installer;
|
||||||
import com.jme3.gde.core.scene.SceneApplication;
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
import com.jme3.gde.core.scene.controller.toolbars.CameraToolbar;
|
import com.jme3.gde.core.scene.controller.toolbars.CameraToolbar;
|
||||||
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
@ -50,6 +51,7 @@ import com.jme3.renderer.RenderManager;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
|
import org.openide.util.NbPreferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -418,13 +420,15 @@ public abstract class AbstractCameraController extends AbstractAppState implemen
|
|||||||
public void onMouseButtonEvent(MouseButtonEvent mbe) {
|
public void onMouseButtonEvent(MouseButtonEvent mbe) {
|
||||||
//on a click release we request the focus for the top component
|
//on a click release we request the focus for the top component
|
||||||
//this allow netbeans to catch keyEvents and trigger actions according to keymapping
|
//this allow netbeans to catch keyEvents and trigger actions according to keymapping
|
||||||
if (mbe.isReleased()) {
|
if ("true".equals(NbPreferences.forModule(Installer.class).get("use_lwjgl_canvas", "false"))) {
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
if (mbe.isReleased()) {
|
||||||
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
SceneViewerTopComponent.findInstance().requestActive();
|
SceneViewerTopComponent.findInstance().requestActive();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.gde.core.sceneviewer;
|
package com.jme3.gde.core.sceneviewer;
|
||||||
|
|
||||||
import com.jme3.gde.core.Installer;
|
|
||||||
import com.jme3.gde.core.filters.FilterExplorerTopComponent;
|
import com.jme3.gde.core.filters.FilterExplorerTopComponent;
|
||||||
import com.jme3.gde.core.scene.SceneApplication;
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
import com.jme3.gde.core.scene.SceneRequest;
|
import com.jme3.gde.core.scene.SceneRequest;
|
||||||
@ -49,7 +48,6 @@ import org.openide.awt.UndoRedo;
|
|||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.HelpCtx;
|
import org.openide.util.HelpCtx;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
import org.openide.util.NbPreferences;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top component which displays something.
|
* Top component which displays something.
|
||||||
@ -80,6 +78,7 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
app = SceneApplication.getApplication();
|
app = SceneApplication.getApplication();
|
||||||
// oglCanvas = ((JmeCanvasContext) app.getContext()).getCanvas();
|
// oglCanvas = ((JmeCanvasContext) app.getContext()).getCanvas();
|
||||||
oglCanvas = app.getMainPanel();
|
oglCanvas = app.getMainPanel();
|
||||||
|
oglCanvas.setFocusable(false);
|
||||||
oGLPanel.add(oglCanvas);
|
oGLPanel.add(oglCanvas);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -92,59 +91,61 @@ 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
|
//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.
|
//the oGLPanel may naver have the focus.
|
||||||
if ("true".equals(NbPreferences.forModule(Installer.class).get("use_lwjgl_canvas", "false"))) {
|
// if ("true".equals(NbPreferences.forModule(Installer.class).get("use_lwjgl_canvas", "false"))) {
|
||||||
addMouseWheelListener(new MouseWheelListener() {
|
addMouseWheelListener(new MouseWheelListener() {
|
||||||
|
|
||||||
public void mouseWheelMoved(final MouseWheelEvent e) {
|
public void mouseWheelMoved(final MouseWheelEvent e) {
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||||
|
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
String action = "MouseWheel-";
|
String action = "MouseWheel-";
|
||||||
if (e.getWheelRotation() < 0) {
|
if (e.getWheelRotation() < 0) {
|
||||||
action = "MouseWheel";
|
action = "MouseWheel";
|
||||||
}
|
}
|
||||||
|
if (app.getActiveCameraController() != null) {
|
||||||
app.getActiveCameraController().onAnalog(action, e.getWheelRotation(), 0);
|
app.getActiveCameraController().onAnalog(action, e.getWheelRotation(), 0);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addKeyListener(new KeyListener() {
|
}
|
||||||
|
});
|
||||||
|
addKeyListener(new KeyListener() {
|
||||||
|
|
||||||
public void keyTyped(KeyEvent evt) {
|
public void keyTyped(KeyEvent evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(final KeyEvent evt) {
|
public void keyPressed(final KeyEvent evt) {
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||||
|
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
int code = AwtKeyInput.convertAwtKey(evt.getKeyCode());
|
int code = AwtKeyInput.convertAwtKey(evt.getKeyCode());
|
||||||
KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, false);
|
KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, false);
|
||||||
keyEvent.setTime(evt.getWhen());
|
keyEvent.setTime(evt.getWhen());
|
||||||
if (app.getActiveCameraController() != null) {
|
if (app.getActiveCameraController() != null) {
|
||||||
app.getActiveCameraController().onKeyEvent(keyEvent);
|
app.getActiveCameraController().onKeyEvent(keyEvent);
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void keyReleased(final KeyEvent evt) {
|
public void keyReleased(final KeyEvent evt) {
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
||||||
|
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
int code = AwtKeyInput.convertAwtKey(evt.getKeyCode());
|
int code = AwtKeyInput.convertAwtKey(evt.getKeyCode());
|
||||||
KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, false);
|
KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, false);
|
||||||
keyEvent.setTime(evt.getWhen());
|
keyEvent.setTime(evt.getWhen());
|
||||||
if (app.getActiveCameraController() != null) {
|
if (app.getActiveCameraController() != null) {
|
||||||
app.getActiveCameraController().onKeyEvent(keyEvent);
|
app.getActiveCameraController().onKeyEvent(keyEvent);
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user