Kiwi.Input.Mouse Class
Handles the dispatching/management of Mouse Events on a game. When this class is instantiated a MouseCursor object is also created (on this object) which holds the information that is unique to the mouse cursor, although majority of that information is still accessible inside this object.
Constructor
Kiwi.Input.Mouse
-
game
Parameters:
-
game
Kiwi.GameThe game that this mouse manager belongs to.
Returns:
Item Index
Methods
Properties
- _cursor
- _domElement
- _game
- _onContextMenuBind
- _onMouseDownBind
- _onMouseMoveBind
- _onMouseUpBind
- altKey
- button
- ctrlKey
- cursor
- duration
- isDown
- isUp
- LEFT_BUTTON static
- MIDDLE_BUTTON static
- onContext
- onDown
- onMouseWheel
- onUp
- onWheel
- preventContextMenu
- RIGHT_BUTTON static
- shiftKey
- wheelDeltaX
- wheelDeltaY
- x
- y
Methods
boot
()
public
This method is executed when the DOM has finished loading and thus the MouseManager can start listening for events.
justPressed
-
[duration=200]
Returns a boolean indicating if the mouse was 'justPressed' within a certain timeframe. The default timeframe is 200 milliseconds.
Parameters:
-
[duration=200]
Number optionalThe timeframe that it could have occured in.
Returns:
justReleased
-
[duration=200]
Returns a boolean indicating if the mouse was 'justReleased' within a certain timeframe. The default timeframe is 200 milliseconds.
Parameters:
-
[duration=200]
Number optionalThe timeframe that it could have occured in..
Returns:
objType
()
String
public
The type of object that this is.
Returns:
"Mouse"
onContextMenu
-
event
Fired when the context menu event is fired. Used to prevent the context menu from appearing when the 'preventContextMenu' property is set to true.
This event is currently only used when targetting browsers and will not fire for CocoonJS.
Parameters:
-
event
Object
onMouseDown
-
event.
Method that gets fired when the mouse is pressed on the stage.
Parameters:
-
event.
MouseEvent
onMouseMove
-
event.
Method that gets fired when the mouse moves anywhere on the stage.
Parameters:
-
event.
MouseEvent
onMouseUp
-
event.
Method that gets fired when the mouse is released on the stage.
Parameters:
-
event.
MouseEvent
onMouseWheel
-
event.
Method that gets fired when the mousewheel is moved.
Parameters:
-
event.
MouseEvent
reset
()
public
Runs the Reset method on the MouseCursor.
start
()
public
Start the mouse event listeners on the game. Automatically called by the boot.
stop
()
public
Stops the mouse event listeners from working. Useful if you no longer want the mouse to 'work'/be listened to.
update
()
public
The update loop for the cursor.
Properties
_cursor
Kiwi.Input.MouseCursor
private
The MouseCursor that is on the stage. This contains the coordinates and information about the cursor.
_domElement
HTMLDivElement
private
The HTMLElement that is being used to apply the mouse events to.
_onContextMenuBind
Function
private
The binding of the 'onContextMenu' method.
_onMouseDownBind
Function
private
The binding of the 'onMouseDown' method.
_onMouseMoveBind
Function
private
The binding of the 'onMouseMove' method.
_onMouseUpBind
Function
private
The binding of the 'onMouseUp' method.
altKey
Boolean
public
Indicates if the alt key is down.
Default: false
ctrlKey
Boolean
public
Indicates if the ctrl key is down.
Default: false
cursor
Kiwi.Input.MouseCursor
private
Returns the MouseCursor that is being used on the stage. This is READ ONLY.
duration
Number
public
Gets the duration in Milliseconds that the mouse cursor has either been up or down for.
isDown
Boolean
public
Indicates whether or not the cursor is currently down. This is READ ONLY.
Default: false
isUp
Boolean
public
Indicates whether or not the cursor is currently up. This is READ ONLY.
Default: true
LEFT_BUTTON
Number
public
final
static
The numeric value for the LEFT button.
Default: 0
MIDDLE_BUTTON
Number
public
final
static
The numeric value for the MIDDLE button.
Default: 1
onContext
Kiwi.Signal
public
Dispatches events when the context menu is fired.
Functions fired from this Signal will have the a single argument being the event of the 'contextmenu' gives.
onDown
Kiwi.Signal
public
A Signal that dispatches events when the mouse is pressed down on the stage.
onMouseWheel
Function
private
The binding of the 'onMouseWheel' method.
onUp
Kiwi.Signal
public
A Signal that dispatches events when the mouse is released from being down on the stage.
preventContextMenu
Boolean
public
Determines whether or not the context menu should appear when the user 'right clicks' on the stage.
Only has an effect on games targetting browsers.
Default: false
RIGHT_BUTTON
Number
public
final
static
The numeric value for the RIGHT button.
Default: 2
shiftKey
Boolean
public
Indicates if the shift key is down.
Default: false
wheelDeltaX
Number
public
Gets the wheelDeltaX coordinate of the mouse cursors wheel.
wheelDeltaY
Number
public
Gets the wheelDeltaY coordinate of the mouse cursors wheel.
x
Number
public
Gets the x coordinate of the mouse cursor.
y
Number
public
Gets the y coordinate of the mouse cursor.