Class TeaInputDevice
- java.lang.Object
-
- nl.colorize.multimedialib.renderer.teavm.TeaInputDevice
-
- All Implemented Interfaces:
InputDevice,Updatable
public class TeaInputDevice extends java.lang.Object implements InputDevice, Updatable
Captures browser events for various input methods, and makes them accessible from the animation loop. During each frame, incoming events are added to a buffer. When the frame update takes place, the buffer is processed to determine the current state for each input device.
-
-
Constructor Summary
Constructors Constructor Description TeaInputDevice(Canvas canvas, nl.colorize.util.PlatformFamily platform)
-
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(KeyCode keyCode)Returns true if the key with the specified key code was pressed during the current frame.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.java.lang.StringrequestTextInput(java.lang.String label, java.lang.String initialValue)Shows a dialog window requesting the user to enter text.voidupdate(float deltaTime)Updates this object for the current frame.
-
-
-
Constructor Detail
-
TeaInputDevice
public TeaInputDevice(Canvas canvas, nl.colorize.util.PlatformFamily platform)
-
-
Method Detail
-
update
public void update(float deltaTime)
Description copied from interface:UpdatableUpdates this object for the current frame.
-
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
-
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
-
requestTextInput
public java.lang.String requestTextInput(java.lang.String label, 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
-
-