Input event object management for rlEngine input events.
Methods
-
(static) createEmptyMouseButtonState() → {rlInputEvent.mouseButtonState}
-
Creates a
rlInputEvent.mouseButtonStatewhere every property is false.Returns:
-
(static) createEmptyMouseKeyboardEvent() → {rlInputEvent.mouseKeyboardEvent}
-
Creates a
rlInputEvent.mouseKeyboardEventwhere every property is empty, 0 or false.Returns:
-
(static) createMouseKeyboardEvent(type, tick, rx, ry, cx, cy, inside, buttons, keys, rlKeyId, printableChar) → {rlInputEvent.mouseKeyboardEvent}
-
Creates a
rlInputEvent.mouseKeyboardEvent(parameters as described there / parameters are cloned into the created event).Parameters:
Name Type Description typestring ticknumber rxnumber rynumber cxnumber cynumber insideboolean buttonsrlInputEvent.mouseButtonState keysrlKeys.keyState rlKeyIdstring printableCharstring Returns:
-
(static) getKeyState(keyId, keyState) → {boolean}
-
Test if a given keyId is active in a given keyState.
Parameters:
Name Type Description keyIdstring a well known Refugee Lib key ID or a printable char
keyStaterlKeys.keyState the key state to examine
Returns:
true if the bit is set, false if it is not
- Type
- boolean
-
(static) isButtonDownEvent(previousEvent, currentEvent, button) → {boolean}
-
Compares the states in two
rlInputEvent.mouseKeyboardEvents and determines whether a given button changed from not pressed to pressed.Parameters:
Name Type Description previousEventrlInputEvent.mouseKeyboardEvent currentEventrlInputEvent.mouseKeyboardEvent buttonstring "left" | "middle" | "right" | "wheelUp" | "wheelDown"
Returns:
- Type
- boolean
-
(static) isButtonUpEvent(previousEvent, currentEvent, button) → {boolean}
-
Compares the states in two
rlInputEvent.mouseKeyboardEvents and determines whether a given button changed from pressed to not pressed.Parameters:
Name Type Description previousEventrlInputEvent.mouseKeyboardEvent currentEventrlInputEvent.mouseKeyboardEvent buttonstring "left" | "middle" | "right" | "wheelUp" | "wheelDown"
Returns:
- Type
- boolean
-
(static) isKeyDownEvent(previousEvent, currentEvent, keyIdOrChar) → {boolean}
-
Compares the states in two
rlInputEvent.mouseKeyboardEvents and determines whether a given key changed from not pressed to pressed.Parameters:
Name Type Description previousEventrlInputEvent.mouseKeyboardEvent currentEventrlInputEvent.mouseKeyboardEvent keyIdOrCharstring one of the IDs described in
rlKeysor a printable characterReturns:
- Type
- boolean
-
(static) isKeyUpEvent(previousEvent, currentEvent, keyIdOrChar) → {boolean}
-
Compares the states in two
rlInputEvent.mouseKeyboardEvents and determines whether a given key changed from pressed to not pressed.Parameters:
Name Type Description previousEventrlInputEvent.mouseKeyboardEvent currentEventrlInputEvent.mouseKeyboardEvent keyIdOrCharstring one of the IDs described in
rlKeysor a printable characterReturns:
- Type
- boolean
Type Definitions
-
mouseButtonState
-
(not an actual type, use object literals with these properties)
each property is true if the corresponding mouse button or wheel state is set, false otherwiseProperties:
Name Type Description leftboolean middleboolean rightboolean wheelUpboolean wheelDownboolean -
mouseKeyboardEvent
-
(not an actual type, use object literals with these properties)
Properties:
Name Type Description typestring the abbreviated type of the event ("md", "mu", "mw", "kd", "kp", "ku") (mousedown, mouseup, mousewheel, keydown, keypress, keyup)
ticknumber the logic tick the engine was at when the event occured
rxnumber position of the mouse on the horizontal axis relative to the leftmost pixel column of the engines view area
rynumber position of the mouse on the vertical axis relative to the topmost pixel row of the engines view area
cxnumber same as rx but capped to the range [0, engines view width -1]
cynumber same as ry but capped to the range [0, engines view height -1]
insideboolean true if the mouse is inside the engines view area
buttonsrlInputEvent.mouseButtonState the state of the mouse buttons & wheel
keysrlKeys.keyState the keyboard state
rlKeyIdstring "None" for mouse events or one of the IDs described in
rlKeysfor keyboard eventsprintableCharstring an empty string if a keyboard event should not produce a character, otherwise it contains the character to produce