Class InputManager
-
- All Implemented Interfaces:
public final class InputManagerHandles input events and passes them to the correct components/layouts.
-
-
Constructor Summary
Constructors Constructor Description InputManager(Drawable master, KeyBinder keyBinder, Settings settings)
-
Method Summary
Modifier and Type Method Description final DrawablegetMouseOver()final FloatgetMouseX()final FloatgetMouseY()final ModifiersgetKeyModifiers()final BytegetMods()the current key modifiers (raw). final DrawablegetFocused()final BooleangetMouseDown()weather or not the left button/primary click is DOWN (aka repeating) final KeyBindergetKeyBinder()final UnitsetKeyBinder(KeyBinder keyBinder)final InputManagerwith(Drawable master)final UnitfilesDropped(Array<Path> files)Call this method when files are dropped onto this window. final UnitkeyTyped(Character key)This method should be called when a printable key is typed. final UnitkeyDown(Keys key)This method should be called when a non-printable, but representable key is pressed. final UnitkeyDown(Integer code)This method should be called when a non-representable key is pressed. final UnitkeyUp(Keys key)This method should be called when a non-printable, but representable key is released. final UnitkeyUp(Integer code)This method should be called when a non-representable key is released. final Unitrecalculate()force the mouse position to be updated. final Unitdrop(Drawable it)Drop the current mouse over drawable. final UnitaddModifier(Byte modifier)add a modifier to the current keyModifiers. final UnitremoveModifier(Byte modifier)remove a modifier from the current keyModifiers. final UnitclearModifiers()Clear the current keyModifiers. final DrawablerayCheck(Drawable it, Float x, Float y)perform a recursive ray check on the drawable. final DrawablerayCheckUnsafe(Drawable it, Float x, Float y)same as rayCheck, but does not check for Drawable.acceptsInput. final UnitmouseMoved(Float x, Float y)call this function to update the mouse position. final UnitmousePressed(Integer button)final UnitmouseReleased(Integer button)call this function when a mouse button is released. final BooleansafeFocus(Drawable drawable)try to focus a drawable, without throwing an exception. final UnitmouseScrolled(Float amountX, Float amountY)call this function when the mouse is scrolled. final Booleandispatch(Event event, Boolean bindable, Drawable to)Dispatch an event to the provided drawable. final Booleanfocus(Drawable focusable)Sets the focus to the specified focusable element, throwing an exception if the provided element is not focusable. -
-
Method Detail
-
getMouseOver
final Drawable getMouseOver()
-
getKeyModifiers
final Modifiers getKeyModifiers()
-
getFocused
final Drawable getFocused()
-
getMouseDown
final Boolean getMouseDown()
weather or not the left button/primary click is DOWN (aka repeating)
-
getKeyBinder
final KeyBinder getKeyBinder()
-
setKeyBinder
final Unit setKeyBinder(KeyBinder keyBinder)
- Parameters:
keyBinder- the key binder to use for this event manager.
-
with
final InputManager with(Drawable master)
-
filesDropped
final Unit filesDropped(Array<Path> files)
Call this method when files are dropped onto this window. The Event.Focused.FileDrop is then dispatched to the currently focused drawable.
- Since:
1.0.3
-
keyTyped
final Unit keyTyped(Character key)
This method should be called when a printable key is typed. This key should be mapped to the user's keyboard layout!
-
keyDown
final Unit keyDown(Keys key)
This method should be called when a non-printable, but representable key is pressed.
-
keyDown
final Unit keyDown(Integer code)
This method should be called when a non-representable key is pressed.
This is used solely for keybinding, and so the key can be any value, as long as it is consistent, and unique to that key.
-
keyUp
final Unit keyUp(Keys key)
This method should be called when a non-printable, but representable key is released.
-
keyUp
final Unit keyUp(Integer code)
This method should be called when a non-representable key is released.
This is used solely for keybinding, and so the key can be any value, as long as it is consistent, and unique to that key.
-
recalculate
final Unit recalculate()
force the mouse position to be updated.
- Since:
0.18.5
-
addModifier
final Unit addModifier(Byte modifier)
add a modifier to the current keyModifiers.
-
removeModifier
final Unit removeModifier(Byte modifier)
remove a modifier from the current keyModifiers.
-
clearModifiers
final Unit clearModifiers()
Clear the current keyModifiers.
- Since:
0.20.1
-
rayCheck
@ApiStatus.Experimental()@Contract(pure = true) final Drawable rayCheck(Drawable it, Float x, Float y)
perform a recursive ray check on the drawable. Each drawable will be checked with Drawable.enabled, then Drawable.isInside, then finally Drawable.acceptsInput before it is considered a valid candidate.
Note that this functions inclusion in public API is experimental.
- Since:
1.0.7
-
rayCheckUnsafe
@ApiStatus.Experimental()@Contract(pure = true) final Drawable rayCheckUnsafe(Drawable it, Float x, Float y)
same as rayCheck, but does not check for Drawable.acceptsInput.
-
mouseMoved
final Unit mouseMoved(Float x, Float y)
call this function to update the mouse position.
-
mousePressed
final Unit mousePressed(Integer button)
-
mouseReleased
final Unit mouseReleased(Integer button)
call this function when a mouse button is released.
-
safeFocus
final Boolean safeFocus(Drawable drawable)
try to focus a drawable, without throwing an exception.
- Returns:
trueif the drawable was focused successfully, andfalseif it is not Drawable.focusable, or if it is already focused.- Since:
1.0.4
-
mouseScrolled
final Unit mouseScrolled(Float amountX, Float amountY)
call this function when the mouse is scrolled.
-
dispatch
final Boolean dispatch(Event event, Boolean bindable, Drawable to)
Dispatch an event to the provided drawable.
If the candidate drawable does not accept the event (returns
false), it will be given to the parent, and so on.Note that changing of the to parameter is experimental.
- Parameters:
bindable- (mostly internal parameter) iftrue, the event will be given to the keyBinder for processing of keybindings, before being given to the candidate drawable.
-
focus
final Boolean focus(Drawable focusable)
Sets the focus to the specified focusable element, throwing an exception if the provided element is not focusable.
- Parameters:
focusable- the element to set focus on- Returns:
true if focus was successfully set, false if the provided focusable is already focused
-
-
-
-