Input event object management for rlEngine
input events.
Methods
-
(static) createEmptyMouseButtonState() → {rlInputEvent.mouseButtonState}
-
Creates a
rlInputEvent.mouseButtonState
where every property is false.Returns:
-
(static) createEmptyMouseKeyboardEvent() → {rlInputEvent.mouseKeyboardEvent}
-
Creates a
rlInputEvent.mouseKeyboardEvent
where 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 type
string tick
number rx
number ry
number cx
number cy
number inside
boolean buttons
rlInputEvent.mouseButtonState keys
rlKeys.keyState rlKeyId
string printableChar
string Returns:
-
(static) getKeyState(keyId, keyState) → {boolean}
-
Test if a given keyId is active in a given keyState.
Parameters:
Name Type Description keyId
string a well known Refugee Lib key ID or a printable char
keyState
rlKeys.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.mouseKeyboardEvent
s and determines whether a given button changed from not pressed to pressed.Parameters:
Name Type Description previousEvent
rlInputEvent.mouseKeyboardEvent currentEvent
rlInputEvent.mouseKeyboardEvent button
string "left" | "middle" | "right" | "wheelUp" | "wheelDown"
Returns:
- Type
- boolean
-
(static) isButtonUpEvent(previousEvent, currentEvent, button) → {boolean}
-
Compares the states in two
rlInputEvent.mouseKeyboardEvent
s and determines whether a given button changed from pressed to not pressed.Parameters:
Name Type Description previousEvent
rlInputEvent.mouseKeyboardEvent currentEvent
rlInputEvent.mouseKeyboardEvent button
string "left" | "middle" | "right" | "wheelUp" | "wheelDown"
Returns:
- Type
- boolean
-
(static) isKeyDownEvent(previousEvent, currentEvent, keyIdOrChar) → {boolean}
-
Compares the states in two
rlInputEvent.mouseKeyboardEvent
s and determines whether a given key changed from not pressed to pressed.Parameters:
Name Type Description previousEvent
rlInputEvent.mouseKeyboardEvent currentEvent
rlInputEvent.mouseKeyboardEvent keyIdOrChar
string one of the IDs described in
rlKeys
or a printable characterReturns:
- Type
- boolean
-
(static) isKeyUpEvent(previousEvent, currentEvent, keyIdOrChar) → {boolean}
-
Compares the states in two
rlInputEvent.mouseKeyboardEvent
s and determines whether a given key changed from pressed to not pressed.Parameters:
Name Type Description previousEvent
rlInputEvent.mouseKeyboardEvent currentEvent
rlInputEvent.mouseKeyboardEvent keyIdOrChar
string one of the IDs described in
rlKeys
or 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 left
boolean middle
boolean right
boolean wheelUp
boolean wheelDown
boolean -
mouseKeyboardEvent
-
(not an actual type, use object literals with these properties)
Properties:
Name Type Description type
string the abbreviated type of the event ("md", "mu", "mw", "kd", "kp", "ku") (mousedown, mouseup, mousewheel, keydown, keypress, keyup)
tick
number the logic tick the engine was at when the event occured
rx
number position of the mouse on the horizontal axis relative to the leftmost pixel column of the engines view area
ry
number position of the mouse on the vertical axis relative to the topmost pixel row of the engines view area
cx
number same as rx but capped to the range [0, engines view width -1]
cy
number same as ry but capped to the range [0, engines view height -1]
inside
boolean true if the mouse is inside the engines view area
buttons
rlInputEvent.mouseButtonState the state of the mouse buttons & wheel
keys
rlKeys.keyState the keyboard state
rlKeyId
string "None" for mouse events or one of the IDs described in
rlKeys
for keyboard eventsprintableChar
string an empty string if a keyboard event should not produce a character, otherwise it contains the character to produce