Class KeyBinder
-
- All Implemented Interfaces:
public final class KeyBinderKeyBinder handles key bindings for the PolyUI instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classKeyBinder.Bind
-
Field Summary
Fields Modifier and Type Field Description private final BooleanhasTimeSensitiveListeners
-
Method Summary
Modifier and Type Method Description final BooleangetHasTimeSensitiveListeners()Property which enables an optimization where the KeyBinder will only update after every frame if there are time-sensitive listeners. final Booleanaccept(Event event)accept a keystroke event. final Booleanaccept(Integer key, Boolean down)accept an unmapped keystroke event. final Booleanupdate(Long deltaTimeNanos, Byte keyModifiers)final Unitadd(KeyBinder.Bind binds)Add a keybind to this PolyUI instance, that will be run when the given keys are pressed. final Unitadd(KeyBinder.Bind bind)Add a keybind to this PolyUI instance, that will be run when the given keys are pressed. final Unitremove(KeyBinder.Bind bind)final Unitremove(KeyBinder.Bind binds)final Unitrecord(Long holdDurationNanos, Function1<KeyBinder.Bind, Unit> callback, Function0<Boolean> function)Begin recording for a keybind. final UnitcancelRecord(String reason)-
-
Constructor Detail
-
KeyBinder
KeyBinder(Settings settings)
-
-
Method Detail
-
getHasTimeSensitiveListeners
final Boolean getHasTimeSensitiveListeners()
Property which enables an optimization where the KeyBinder will only update after every frame if there are time-sensitive listeners.
- Since:
1.1.1
-
accept
@ApiStatus.Internal() final Boolean accept(Event event)
accept a keystroke event. This will call all keybindings that match the event.
This method is public, but marked as internal. This is because it should only be called by the PolyUI instance, unless you are trying to externally force a keypress (which you probably shouldn't be)
-
accept
@ApiStatus.Internal() final Boolean accept(Integer key, Boolean down)
accept an unmapped keystroke event. This will call all keybindings that match the event.
This method is public, but marked as internal. This is because it should only be called by the PolyUI instance, unless you are trying to externally force a keypress (which you probably shouldn't be)
-
add
final Unit add(KeyBinder.Bind binds)
Add a keybind to this PolyUI instance, that will be run when the given keys are pressed.
- Since:
1.1.7
-
add
final Unit add(KeyBinder.Bind bind)
Add a keybind to this PolyUI instance, that will be run when the given keys are pressed.
- Since:
0.21.0
-
remove
final Unit remove(KeyBinder.Bind bind)
-
remove
final Unit remove(KeyBinder.Bind binds)
-
record
final Unit record(Long holdDurationNanos, Function1<KeyBinder.Bind, Unit> callback, Function0<Boolean> function)
Begin recording for a keybind.
recording may be cancelled for the following reasons:
the ESC key is pressed
record is called again before the recording is completed, (i.e. starting a new one before the old one is finished)
the instance already has a keybind which matched the one being recorded
the keybind was attempted to be set to just left-click (which is not allowed)
- Parameters:
holdDurationNanos- the duration that the keys have to be pressed in the resultant keybindcallback- the function that will be called when recording is completed.function- the function that will be run when the keybind is pressed- Since:
0.24.0
-
cancelRecord
@ApiStatus.Internal() final Unit cancelRecord(String reason)
-
-
-
-