Package playn.core
Class Input
java.lang.Object
playn.core.Input
-
Field Summary
Modifier and TypeFieldDescriptionA signal emitted when the game application gains or loses focus.boolean
Enables or disables keyboard interaction.A signal via which keyboard events are emitted.boolean
Enables or disables mouse interaction.A signal which emits mouse events.boolean
Enables or disables touch interaction.A signal via which touch events are emitted. -
Method Summary
Modifier and TypeMethodDescriptiongetText
(Keyboard.TextType textType, String label, String initialValue) Requests a line of text from the user.Requests a line of text from the user.boolean
Returns true if this device has a hardware keyboard, false if not.boolean
hasMouse()
Returns true if this platform has mouse input.boolean
Returns true if this platform supports mouse locking.boolean
hasTouch()
Returns true if this platform has touch input.boolean
Returns whether the mouse is currently locked.void
setMouseLocked
(boolean locked) Lock or unlock the mouse.Displays a system dialog with the specified title and text, an OK button and optionally a Cancel button.
-
Field Details
-
mouseEnabled
public boolean mouseEnabledEnables or disables mouse interaction. No mouse events will be dispatched whilst this big switch is in the off position. -
touchEnabled
public boolean touchEnabledEnables or disables touch interaction. No touch events will be dispatched whilst this big switch is in the off position. -
keyboardEnabled
public boolean keyboardEnabledEnables or disables keyboard interaction. No keyboard events will be dispatched whilst this big switch is in the off position. -
mouseEvents
A signal which emits mouse events. -
touchEvents
A signal via which touch events are emitted. -
keyboardEvents
A signal via which keyboard events are emitted. -
focus
A signal emitted when the game application gains or loses focus.
-
-
Method Details
-
hasMouse
public boolean hasMouse()Returns true if this platform has mouse input. -
hasTouch
public boolean hasTouch()Returns true if this platform has touch input. -
hasHardwareKeyboard
public boolean hasHardwareKeyboard()Returns true if this device has a hardware keyboard, false if not. Devices that lack a hardware keyboard will generally not generate keyboard events. Older Android devices that support four hardware buttons are an exception. UsegetText(playn.core.Keyboard.TextType, java.lang.String, java.lang.String)
for text entry on a non-hardware-keyboard having device. -
hasMouseLock
public boolean hasMouseLock()Returns true if this platform supports mouse locking. The user may still block it when it is requested, or detection may be broken for some browsers. -
isMouseLocked
public boolean isMouseLocked()Returns whether the mouse is currently locked. -
setMouseLocked
public void setMouseLocked(boolean locked) Lock or unlock the mouse. When the mouse is locked, mouse events are still received even when the pointer leaves the game window. -
getText
Requests a line of text from the user. On platforms that have only a virtual keyboard, this will display a text entry interface, obtain the line of text, and dismiss the text entry interface when finished.- Parameters:
textType
- the expected type of text. On mobile devices this hint may be used to display a keyboard customized to the particular type of text.label
- a label to display over the text entry interface, may be null.initialValue
- the initial value to display in the text input field, may be null.- Returns:
- a future which provides the text when it becomes available. If the user cancels the text entry process, null is supplied. Otherwise the entered text is supplied.
-
getText
public RFuture<String> getText(Keyboard.TextType textType, String label, String initialValue, String ok, String cancel) Requests a line of text from the user. On platforms that have only a virtual keyboard, this will display a text entry interface, obtain the line of text, and dismiss the text entry interface when finished. Note that HTML5 and some Java backends do not support customization of the OK and Cancel labels. Thus those platforms will ignore the supplied labels and use their mandatory labels.- Parameters:
textType
- the expected type of text. On mobile devices this hint may be used to display a keyboard customized to the particular type of text.label
- a label to display over the text entry interface, may be null.initialValue
- the initial value to display in the text input field, may be null.ok
- the text of the button which will deliver atrue
result and be placed in "OK" position for the platform.cancel
- the text of the button that will deliver afalse
result and be placed in "Cancel" position.- Returns:
- a future which provides the text when it becomes available. If the user cancels the text entry process, null is supplied. Otherwise the entered text is supplied.
-
sysDialog
Displays a system dialog with the specified title and text, an OK button and optionally a Cancel button.- Parameters:
title
- the title for the dialog window. Note: some platforms (mainly mobile) do not display the title, so be sure your dialog makes sense if onlytext
is showing.text
- the text of the dialog. The text will be wrapped by the underlying platform, but PlayN will do its utmost to ensure that newlines are honored by the platform in question so that hard line breaks and blank lines are reproduced correctly.ok
- the text of the button which will deliver atrue
result and be placed in "OK" position for the platform. Note: the HTML platform does not support customizing this label, so on that platform the label will be "OK". Yay for HTML5.cancel
- the text of the button that will deliver afalse
result and be placed in "Cancel" position. Ifnull
is supplied, the dialog will only have an OK button. Note: the HTML platform does not support customizing this label, so on that platform a non-null cancel string will result in the button reading "Cancel". Yay for HTML5.- Returns:
- a future which delivers
true
orfalse
when the user clicks the OK or cancel buttons respectively. If some unexpected error occurs displaying the dialog (unlikley), it will be reported by failing the future.
-