Class InputManager
-
- All Implemented Interfaces:
public final class InputManagerHandles input events and passes them to the correct components/layouts.
-
-
Field Summary
Fields Modifier and Type Field Description private final InputtablemouseOverprivate final FloatmouseXprivate final FloatmouseYprivate final Booleandraggingprivate final ModifierskeyModifiersprivate final Bytemodsprivate final Inputtablefocusedprivate final BooleanmouseDownprivate KeyBinderkeyBinder
-
Constructor Summary
Constructors Constructor Description InputManager(Inputtable master, KeyBinder keyBinder, Settings settings)
-
Method Summary
Modifier and Type Method Description final InputtablegetMouseOver()final FloatgetMouseX()final FloatgetMouseY()final BooleangetDragging()trueif the mouse is currently dragging.final ModifiersgetKeyModifiers()final BytegetMods()the current key modifiers (raw). final InputtablegetFocused()final BooleangetMouseDown()weather or not the left button/primary click is DOWN (aka repeating) final KeyBindergetKeyBinder()final UnitsetKeyBinder(KeyBinder keyBinder)final InputManagerwith(Inputtable 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(Inputtable it)Drop the current mouse over component. 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 InputtablerayCheck(Inputtable it, Float x, Float y)perform a recursive ray check on the component. final ComponentrayCheckUnsafe(Component it, Float x, Float y)same as rayCheck, but does not check for Inputtable.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(Inputtable component)try to focus a component, without throwing an exception. final UnitmouseScrolled(Float amountX, Float amountY)call this function when the mouse is scrolled. final Booleandispatch(Event event, Boolean bindable, Inputtable to)Dispatch an event to the provided component. final Unitunfocus()final Unitunfocus(Inputtable target)Unfocus the target if it currently is the focused drawable. final Booleanfocus(Inputtable focusable)Sets the focus to the specified focusable element, throwing an exception if the provided element is not focusable. -
-
Constructor Detail
-
InputManager
InputManager(Inputtable master, KeyBinder keyBinder, Settings settings)
- Parameters:
master- the layout to create this event manager for.keyBinder- the key binder to use for this event manager.
-
-
Method Detail
-
getMouseOver
final Inputtable getMouseOver()
-
getDragging
final Boolean getDragging()
trueif the mouse is currently dragging.- Since:
1.6.1
-
getKeyModifiers
final Modifiers getKeyModifiers()
-
getFocused
final Inputtable 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(Inputtable 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 component.
- 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
-
drop
@ApiStatus.Internal() final Unit drop(Inputtable it)
Drop the current mouse over component.
-
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 Inputtable rayCheck(Inputtable it, Float x, Float y)
perform a recursive ray check on the component. Each component will be checked with Component.isEnabled, then Component.isInside, then finally Inputtable.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 Component rayCheckUnsafe(Component it, Float x, Float y)
same as rayCheck, but does not check for Inputtable.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(Inputtable component)
try to focus a component, without throwing an exception.
- Returns:
trueif the component was focused successfully, andfalseif it is not Inputtable.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, Inputtable to)
Dispatch an event to the provided component.
If the candidate component 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 component.
-
unfocus
final Unit unfocus(Inputtable target)
- Since:
1.6.1
-
focus
final Boolean focus(Inputtable 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
-
-
-
-