User inputs are handled by the InputHandler,
which is part of SceneryBase
and Hubable
. Adding inputs can be done in an overwrite of the inputSetup
method of SceneryBase
. First a Behavior
needs to be added before a key can be assigned.
A behavior defines an action which is executed when the corresponding keys are pressed. There are currently the following base behaviors from which can be inherited: ClickBehavior
, DragBehavior
, ScrollBehavior
.
In most cases a ClickBehavior
is used. Example:
In cases where the x
and y
screen positions of the cursor are not needed, they are just ignored. Adding a behavior to the InputHandler
is straightforward:
inputHandler
should be available from an overwrite of the inputSetup
method.
Assigning keys to a behavior works in a similar fashion:
This code assigned the earlier added behavior to the first mouse button.
Does the same but for the "M" key.
For more info on the available keys and combinations thereof see InputTrigger syntax