/** Applies a mouse scroll event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the\r
* event. This event only occurs on the desktop. */\r
public boolean scrolled (int amount) {\r
- if (scrollFocus == null) return false;\r
+ Actor target = scrollFocus == null ? root : scrollFocus;\r
\r
screenToStageCoordinates(stageCoords.set(mouseScreenX, mouseScreenY));\r
\r
event.setScrollAmount(amount);\r
event.setStageX(stageCoords.x);\r
event.setStageY(stageCoords.y);\r
- scrollFocus.fire(event);\r
+ target.fire(event);\r
boolean handled = event.isHandled();\r
Pools.free(event);\r
return handled;\r
/** Applies a key down event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns\r
* true if the event was {@link Event#handle() handled}. */\r
public boolean keyDown (int keyCode) {\r
- if (keyboardFocus == null) return false;\r
+ Actor target = keyboardFocus == null ? root : keyboardFocus;\r
InputEvent event = Pools.obtain(InputEvent.class);\r
event.setStage(this);\r
event.setType(InputEvent.Type.keyDown);\r
event.setKeyCode(keyCode);\r
- keyboardFocus.fire(event);\r
+ target.fire(event);\r
boolean handled = event.isHandled();\r
Pools.free(event);\r
return handled;\r
/** Applies a key up event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns true\r
* if the event was {@link Event#handle() handled}. */\r
public boolean keyUp (int keyCode) {\r
- if (keyboardFocus == null) return false;\r
+ Actor target = keyboardFocus == null ? root : keyboardFocus;\r
InputEvent event = Pools.obtain(InputEvent.class);\r
event.setStage(this);\r
event.setType(InputEvent.Type.keyUp);\r
event.setKeyCode(keyCode);\r
- keyboardFocus.fire(event);\r
+ target.fire(event);\r
boolean handled = event.isHandled();\r
Pools.free(event);\r
return handled;\r
/** Applies a key typed event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns\r
* true if the event was {@link Event#handle() handled}. */\r
public boolean keyTyped (char character) {\r
- if (keyboardFocus == null) return false;\r
+ Actor target = keyboardFocus == null ? root : keyboardFocus;\r
InputEvent event = Pools.obtain(InputEvent.class);\r
event.setStage(this);\r
event.setType(InputEvent.Type.keyTyped);\r
event.setCharacter(character);\r
- keyboardFocus.fire(event);\r
+ target.fire(event);\r
boolean handled = event.isHandled();\r
Pools.free(event);\r
return handled;\r