Class EventManager
-
- All Implemented Interfaces:
public final class EventManagerHandles all events and passes them to the correct components/layouts.
-
-
Field Summary
Fields Modifier and Type Field Description private final DrawablemouseOverprivate final DrawableprimaryCandidateprivate final FloatmouseXprivate final FloatmouseYprivate final BooleanisOnMacprivate final ShortkeyModifiersprivate final BooleanhasFocusedprivate final BooleanmouseDownprivate Layoutlayoutprivate KeyBinderkeyBinder
-
Constructor Summary
Constructors Constructor Description EventManager(Layout layout, KeyBinder keyBinder, Settings settings)EventManager(KeyBinder keyBinder, Settings settings)
-
Method Summary
Modifier and Type Method Description final DrawablegetMouseOver()final DrawablegetPrimaryCandidate()final FloatgetMouseX()final FloatgetMouseY()final BooleanisOnMac()If the current OS is detected as macOS final ShortgetKeyModifiers()final BooleangetHasFocused()final BooleangetMouseDown()weather or not the left button/primary click is DOWN (aka repeating) final LayoutgetLayout()final UnitsetLayout(Layout layout)final KeyBindergetKeyBinder()final UnitsetKeyBinder(KeyBinder keyBinder)final EventManagerwith(Layout layout)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 UnitrecalculateMousePos()Internal function that will force the mouse position to be updated. final Unitdrop(Drawable drawable, Boolean withChildren)Internal function that will forcefully drop the given drawable from event tracking. final UnitaddModifier(Short modifier)add a modifier to the current keyModifiers. final UnitremoveModifier(Short modifier)remove a modifier from the current keyModifiers. final UnitclearModifiers()Clear the current keyModifiers. final DrawableprocessCandidate(Drawable drawable, Float x, Float y)Internal method for drawables, tracking it if it does not consume the events. 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 BooleantryFocus(Drawable drawable)try to focus a drawable, and return true if it was successful. final UnitmouseScrolled(Float amountX, Float amountY)call this function when the mouse is scrolled. final Booleandispatch(Event event)Dispatch an event to this PolyUI instance, and it will be given to any tracked drawable. final Booleanfocus(Focusable focusable)Sets the focus to the specified focusable element. final Booleanunfocus()-
-
Method Detail
-
getMouseOver
final Drawable getMouseOver()
-
getPrimaryCandidate
final Drawable getPrimaryCandidate()
-
getKeyModifiers
final Short getKeyModifiers()
-
getHasFocused
final Boolean getHasFocused()
-
getMouseDown
final Boolean getMouseDown()
weather or not the left button/primary click is DOWN (aka repeating)
-
setLayout
final Unit setLayout(Layout layout)
- Parameters:
layout- the layout to create this event manager for.
-
getKeyBinder
@ApiStatus.Internal() final KeyBinder getKeyBinder()
-
setKeyBinder
final Unit setKeyBinder(KeyBinder keyBinder)
- Parameters:
keyBinder- the key binder to use for this event manager.
-
with
final EventManager with(Layout layout)
-
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.
-
recalculateMousePos
@ApiStatus.Internal() final Unit recalculateMousePos()
Internal function that will force the mouse position to be updated.
- Since:
0.18.5
-
drop
@ApiStatus.Internal() final Unit drop(Drawable drawable, Boolean withChildren)
Internal function that will forcefully drop the given drawable from event tracking.
-
addModifier
final Unit addModifier(Short modifier)
add a modifier to the current keyModifiers.
-
removeModifier
final Unit removeModifier(Short modifier)
remove a modifier from the current keyModifiers.
-
clearModifiers
final Unit clearModifiers()
Clear the current keyModifiers.
- Since:
0.20.1
-
processCandidate
@ApiStatus.Internal() final Drawable processCandidate(Drawable drawable, Float x, Float y)
Internal method for drawables, tracking it if it does not consume the events.
This is used for event dispatching.
-
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.
-
tryFocus
final Boolean tryFocus(Drawable drawable)
try to focus a drawable, and return true if it was successful.
-
mouseScrolled
final Unit mouseScrolled(Float amountX, Float amountY)
call this function when the mouse is scrolled.
-
dispatch
final Boolean dispatch(Event event)
Dispatch an event to this PolyUI instance, and it will be given to any tracked drawable.
-
focus
final Boolean focus(Focusable focusable)
Sets the focus to the specified focusable element.
- Parameters:
focusable- the element to set focus on- Returns:
true if focus was successfully set, false if the provided focusable is already focused
-
-
-
-