new InputManager(renderer)
Managers inputs, giving an easy to use interface.
An input manager can only be listening to a single renderer
at once.
Parameters:
Name | Type | Description |
---|---|---|
renderer |
Grape2D.Renderer | Renderer to listen. |
- Source:
Members
-
<private, static> globalRegistry :!Object.<string, !(Array.<!Function>|Object.<number, Function>)>
-
Registry of non-specific events.
Type:
- !Object.<string, !(Array.<!Function>|Object.<number, Function>)>
- Source:
-
<private> click :!Array.<Function>
-
Click callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> drag :!Array.<Function>
-
Drag callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> dragStart :Grape2D.Vector
-
Start dragging position.
Type:
- Source:
-
<private> isDragging :boolean
-
Dragging state.
Type:
- boolean
- Source:
-
<private> keyDown :!Object.<number, !Array.<Function>>
-
Key down callback stack.
Type:
- !Object.<number, !Array.<Function>>
- Source:
-
<private> keyPress :!Object.<number, !Array.<Function>>
-
Key press callback stack.
Type:
- !Object.<number, !Array.<Function>>
- Source:
-
<private> keyUp :!Object.<number, !Array.<Function>>
-
Key up callback stack.
Type:
- !Object.<number, !Array.<Function>>
- Source:
-
<private> mouseDown :!Array.<Function>
-
Mouse down callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> mouseMove :!Array.<Function>
-
Mouse move callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> mouseOut :!Array.<Function>
-
Mouse out callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> mouseOver :!Array.<Function>
-
Mouse over callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> mouseUp :!Array.<Function>
-
Mouse up callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> mouseWheel :!Array.<Function>
-
Mouse wheel callback stack.
Type:
- !Array.<Function>
- Source:
-
<private> rendererBinding :Grape2D.Renderer
-
Renderer
Type:
- Source:
-
<private> resize :!Array.<Function>
-
Resize callback stack.
Type:
- !Array.<Function>
- Source:
Methods
-
<protected, static> bindFn(binding, stck) → {Function}
-
This function creates a callback function to be called when a keyboard event occurs.
Parameters:
Name Type Description binding
Grape2D.Renderer Renderer where the input manager is bound. stck
!Array.<Function> List of references to an input manager callback stack. - Source:
Returns:
Callback to an event.- Type
- Function
-
<private, static> keyDispatcher(stck) → {Function}
-
Returns a function that dispatches the callbacks associated with key codes.
Parameters:
Name Type Description stck
!Object.<number, Function> Object with the callbacks associated with the key codes. - Source:
Returns:
Dispatcher function.- Type
- Function
-
<private, static> registerGlobalKeyDown(key, callback)
-
Registers a global callback function, to the key down event. A key down event is triggered by the window, not the renderer, binded.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback to register. - Source:
-
<private, static> registerGlobalKeyPress(key, callback)
-
Registers a global callback function, to the key press event. A key press event is triggered by the window, not the renderer, binded.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback to register. - Source:
-
<private, static> registerGlobalKeyUp(key, callback)
-
Registers a global callback function, to the key up event. A key up event is triggered by the window, not the renderer, binded.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback to register. - Source:
-
<private, static> registerGlobalResize(callback)
-
Registers a global callback function, to the resize event. A resize event is triggered by the window, not the renderer, binded.
Parameters:
Name Type Description callback
Function Callback to register. - Source:
-
<private, static> resizeDispatcher() → {Function}
-
Returns a function that dispatches the callbacks associated with resize event.
- Source:
Returns:
Dispatcher function.- Type
- Function
-
<static> setupGlobals()
-
Setups globals callbacks. It must be called once for this to work.
- Source:
-
<private, static> unregisterGlobalKeyDown(key, callback)
-
Unregisters a global callback function, to the key down event, that has been already registered.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback to unregister. - Source:
-
<private, static> unregisterGlobalKeyPress(key, callback)
-
Unregisters a global callback function, to the key press event, that has been already registered.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback to unregister. - Source:
-
<private, static> unregisterGlobalKeyUp(key, callback)
-
Unregisters a global callback function, to the key up event, that has been already registered.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback to unregister. - Source:
-
<private, static> unregisterGlobalResize(callback)
-
Unregisters a global callback function, to the resize event, that has been already registered.
Parameters:
Name Type Description callback
Function Callback to unregister. - Source:
-
addClick(callback)
-
Adds a callback to the click event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addDrag(callback)
-
Adds a callback to the drag event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addKeyDown(key, callback)
-
Adds a callback to the key down event.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback function. - Source:
-
addKeyPress(key, callback)
-
Adds a callback to the key press event.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback function. - Source:
-
addKeyUp(key, callback)
-
Adds a callback to the key up event.
Parameters:
Name Type Description key
number Key code that triggers the callback. callback
Function Callback function. - Source:
-
addMouseDown(callback)
-
Adds a callback to the mouse down event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addMouseMove(callback)
-
Adds a callback to the mouse move event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addMouseOut(callback)
-
Adds a callback to the mouse out event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addMouseOver(callback)
-
Adds a callback to the mouse over event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addMouseUp(callback)
-
Adds a callback to the mouse up event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addMouseWheel(callback)
-
Adds a callback to the mouse wheel event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
addResize(callback)
-
Adds a callback to the resize event.
Parameters:
Name Type Description callback
Function Callback function. - Source:
-
bindToRenderer(renderer)
-
Binds the renderer to this input manager. Sets up helper functions and callbacks.
Parameters:
Name Type Description renderer
Grape2D.Renderer The renderer to listen. - Source:
-
getClickBindStack() → {!Array.<Function>}
-
Gets the click callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getDragBindStack() → {!Array.<Function>}
-
Gets the drag callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getKeyDownBindStack() → {!Object.<number, !Array.<Function>>}
-
Gets the key down callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Object.<number, !Array.<Function>>
-
getKeyPressBindStack() → {!Object.<number, !Array.<Function>>}
-
Gets the key press callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Object.<number, !Array.<Function>>
-
getKeyUpBindStack() → {!Object.<number, !Array.<Function>>}
-
Gets the key up callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Object.<number, !Array.<Function>>
-
getMouseDownBindStack() → {!Array.<Function>}
-
Gets the mouse down callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getMouseMoveBindStack() → {!Array.<Function>}
-
Gets the mouse move callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getMouseOutBindStack() → {!Array.<Function>}
-
Gets the mouse out callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getMouseOverBindStack() → {!Array.<Function>}
-
Gets the mouse over callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getMouseUpBindStack() → {!Array.<Function>}
-
Gets the mouse up callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getMouseWheelBindStack() → {!Array.<Function>}
-
Gets the mouse wheel callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
getResizeBindStack() → {!Array.<Function>}
-
Gets the resize callback stack, that is binded to the renderer.
- Source:
Returns:
Callback stack.- Type
- !Array.<Function>
-
removeClick(callback)
-
Removes a callback from the click callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeDrag(callback)
-
Removes a callback from the drag callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeKeyDown(key, callback)
-
Removes a callback from the key down callback stack.
Parameters:
Name Type Description key
number Key code of the key that triggers the callback. callback
Function Function to remove - Source:
-
removeKeyPress(key, callback)
-
Removes a callback from the key press callback stack.
Parameters:
Name Type Description key
number Key code of the key that triggers the callback. callback
Function Function to remove - Source:
-
removeKeyUp(key, callback)
-
Removes a callback from the key up callback stack.
Parameters:
Name Type Description key
number Key code of the key that triggers the callback. callback
Function Function to remove - Source:
-
removeMouseDown(callback)
-
Removes a callback from the mouse down callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeMouseMove(callback)
-
Removes a callback from the mouse move callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeMouseOut(callback)
-
Removes a callback from the mouse out callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeMouseOver(callback)
-
Removes a callback from the mouse over callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeMouseUp(callback)
-
Removes a callback from the mouse up callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeMouseWheel(callback)
-
Removes a callback from the mouse wheel callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source:
-
removeResize(callback)
-
Removes a callback from the resize callback stack.
Parameters:
Name Type Description callback
Function Function to remove - Source: