diff --git a/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java b/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java index 12e970d..433329b 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java +++ b/core/src/main/java/edu/umd/cs/piccolo/PInputManager.java @@ -86,10 +86,10 @@ } /** - * Set the node that should recive key events. + * Set the node that should receive key events. */ public void setKeyboardFocus(PInputEventListener eventHandler) { - PInputEvent focusEvent = new PInputEvent(this, null); + PInputEvent focusEvent = new PInputEvent(this, null, null); if (keyboardFocus != null) { dispatchEventToListener(focusEvent, FocusEvent.FOCUS_LOST, keyboardFocus); @@ -228,7 +228,7 @@ if (nextInput == null) return; - PInputEvent e = new PInputEvent(this, nextInput); + PInputEvent e = new PInputEvent(this, nextInput, nextInputSource); Point2D newCurrentCanvasPosition = null; Point2D newLastCanvasPosition = null; diff --git a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java index 6168b0c..a12d597 100644 --- a/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java +++ b/core/src/main/java/edu/umd/cs/piccolo/event/PInputEvent.java @@ -64,12 +64,14 @@ private InputEvent inputEvent; private PPickPath pickPath; private PInputManager inputManager; + private PCamera inputSource; private boolean handled; - public PInputEvent(PInputManager inputManager, InputEvent event) { + public PInputEvent(PInputManager inputManager, InputEvent event, PCamera inputSource) { super(); inputEvent = event; this.inputManager = inputManager; + this.inputSource = inputSource; } public void pushCursor(Cursor cursor) { @@ -100,15 +102,15 @@ * getTopCamera. */ public PCamera getCamera() { - return getPath().getBottomCamera(); + return (getPath() == null) ? inputSource : getPath().getBottomCamera(); } /** - * Return the topmost camera this is painting. This is the camera assocaited + * Return the topmost camera this is painting. This is the camera associated * with the PCanvas that requested the current repaint. */ public PCamera getTopCamera() { - return getPath().getTopCamera(); + return (getPath() == null) ? inputSource : getPath().getTopCamera(); } /**