Class AWTInput
- java.lang.Object
-
- nl.colorize.multimedialib.renderer.java2d.AWTInput
-
- All Implemented Interfaces:
java.awt.event.KeyListener,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.util.EventListener,InputDevice,Updatable
public class AWTInput extends java.lang.Object implements InputDevice, Updatable, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
Input device that uses AWT to capture mouse and keyboard events.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Point2D>getPointers()Returns the current locations of all currently active pointers.booleanisKeyboardAvailable()Returns true if the current device has a hardware keyboard.booleanisKeyPressed(int keycode)booleanisKeyPressed(KeyCode keyCode)Returns true if the key with the specified key code was pressed during the current frame.booleanisKeyReleased(int keycode)booleanisKeyReleased(KeyCode keyCode)Returns true if the key with the specified key code was released during the current frame.booleanisPointerPressed(Rect area)Returns true if any of the currently active pointers have been pressed and located within the specified area during the current frame.booleanisPointerReleased(Rect area)Returns true if any of the currently active pointers were released and located within the specified area during the current frame.booleanisTouchAvailable()Returns if the current device supports touch input.voidkeyPressed(java.awt.event.KeyEvent e)voidkeyReleased(java.awt.event.KeyEvent e)voidkeyTyped(java.awt.event.KeyEvent e)voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)voidmousePressed(java.awt.event.MouseEvent e)voidmouseReleased(java.awt.event.MouseEvent e)java.lang.StringrequestTextInput(java.lang.String labelText, java.lang.String initialValue)Shows a dialog window requesting the user to enter text.voidupdate(float deltaTime)Copies all events that have been received during the last frame to this class' internal state.
-
-
-
Constructor Detail
-
AWTInput
public AWTInput(Canvas canvas)
-
-
Method Detail
-
update
public void update(float deltaTime)
Copies all events that have been received during the last frame to this class' internal state. This method must be called every frame.
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
getPointers
public java.util.List<Point2D> getPointers()
Description copied from interface:InputDeviceReturns the current locations of all currently active pointers. When using a mouse, this will always return a list with a single element. For touch controls, the list could also have multiple elements (during multi-touch gestures) or the list could be empty (unlike mouse events, touch coordinates are only available during the event itself).- Specified by:
getPointersin interfaceInputDevice
-
isPointerPressed
public boolean isPointerPressed(Rect area)
Description copied from interface:InputDeviceReturns true if any of the currently active pointers have been pressed and located within the specified area during the current frame.- Specified by:
isPointerPressedin interfaceInputDevice
-
isPointerReleased
public boolean isPointerReleased(Rect area)
Description copied from interface:InputDeviceReturns true if any of the currently active pointers were released and located within the specified area during the current frame.- Specified by:
isPointerReleasedin interfaceInputDevice
-
isTouchAvailable
public boolean isTouchAvailable()
Description copied from interface:InputDeviceReturns if the current device supports touch input. If true, the values returned byInputDevice.getPointers(),InputDevice.isPointerPressed(Rect), andInputDevice.isPointerReleased(Rect)will be based on touch input. If false, they will be based on mouse or trackpad input.- Specified by:
isTouchAvailablein interfaceInputDevice
-
isKeyboardAvailable
public boolean isKeyboardAvailable()
Description copied from interface:InputDeviceReturns true if the current device has a hardware keyboard.- Specified by:
isKeyboardAvailablein interfaceInputDevice
-
isKeyPressed
public boolean isKeyPressed(KeyCode keyCode)
Description copied from interface:InputDeviceReturns true if the key with the specified key code was pressed during the current frame.- Specified by:
isKeyPressedin interfaceInputDevice
-
isKeyPressed
public boolean isKeyPressed(int keycode)
-
isKeyReleased
public boolean isKeyReleased(KeyCode keyCode)
Description copied from interface:InputDeviceReturns true if the key with the specified key code was released during the current frame.- Specified by:
isKeyReleasedin interfaceInputDevice
-
isKeyReleased
public boolean isKeyReleased(int keycode)
-
requestTextInput
public java.lang.String requestTextInput(java.lang.String labelText, java.lang.String initialValue)Description copied from interface:InputDeviceShows a dialog window requesting the user to enter text. This method exists only because text fields, unlike other input elements such as buttons, cannot be emulated by the renderer without losing common functionality such as copy/paste. Text input must therefore be delegated to the platform so that a native text field can be used.- Specified by:
requestTextInputin interfaceInputDevice
-
-