Event.EventMouse Class
Extends Event
Module: cc
The mouse event
Index
Properties
- NONE- NumberThe none event code of mouse event.
- DOWN- NumberThe event type code of mouse down event.
- UP- NumberThe event type code of mouse up event.
- MOVE- NumberThe event type code of mouse move event.
- SCROLL- NumberThe event type code of mouse scroll event.
- BUTTON_LEFT- NumberThe tag of Mouse left button.
- BUTTON_RIGHT- NumberThe tag of Mouse right button (The right button number is 2 on browser).
- BUTTON_MIDDLE- NumberThe tag of Mouse middle button (The right button number is 1 on browser).
- BUTTON_4- NumberThe tag of Mouse button 4.
- BUTTON_5- NumberThe tag of Mouse button 5.
- BUTTON_6- NumberThe tag of Mouse button 6.
- BUTTON_7- NumberThe tag of Mouse button 7.
- BUTTON_8- NumberThe tag of Mouse button 8.
- type- StringThe name of the event (case-sensitive), e.g. "click", "fire", or "submit".
- bubbles- BooleanIndicate whether the event bubbles up through the tree or not.
- target- ObjectA reference to the target to which the event was originally dispatched.
- currentTarget- ObjectA reference to the currently registered target for the event.
- eventPhase- NumberIndicates which phase of the event flow is currently being evaluated. Returns an integer value represented by 4 constants:- Event.NONE = 0
- Event.CAPTURING_PHASE = 1
- Event.AT_TARGET = 2
- Event.BUBBLING_PHASE = 3 The phases are explained in the [section 3.1, Event dispatch and DOM event flow] (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
 
Methods
- setScrollDataSets scroll data.
- getScrollXReturns the x axis scroll value.
- getScrollYReturns the y axis scroll value.
- setLocationSets cursor location.
- getLocationReturns cursor location.
- getLocationInViewReturns the current cursor location in screen coordinates.
- getPreviousLocationReturns the previous touch location.
- getDeltaReturns the delta distance from the previous location to current location.
- getDeltaXReturns the X axis delta distance from the previous location to current location.
- getDeltaYReturns the Y axis delta distance from the previous location to current location.
- setButtonSets mouse button.
- getButtonReturns mouse button.
- getLocationXReturns location X axis data.
- getLocationYReturns location Y axis data.
- constructor
- unuseReset the event for being stored in the object pool.
- reuseReuse the event for being used again by the object pool.
- stopPropagationStops propagation for current event.
- stopPropagationImmediateStops propagation for current event immediately, the event won't even be dispatched to the listeners attached in the current target.
- isStoppedChecks whether the event has been stopped.
- getCurrentTarget- Gets current target of the event 
 note: It only be available when the event listener is associated with node.
 </p>- It returns 0 when the listener is associated with fixed priority.
- getTypeGets the event type.
Details
Properties
NONE
The none event code of mouse event.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:207 | 
DOWN
The event type code of mouse down event.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:215 | 
UP
The event type code of mouse up event.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:223 | 
MOVE
The event type code of mouse move event.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:231 | 
SCROLL
The event type code of mouse scroll event.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:239 | 
BUTTON_LEFT
The tag of Mouse left button.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:248 | 
BUTTON_RIGHT
The tag of Mouse right button (The right button number is 2 on browser).
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:257 | 
BUTTON_MIDDLE
The tag of Mouse middle button (The right button number is 1 on browser).
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:266 | 
BUTTON_4
The tag of Mouse button 4.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:275 | 
BUTTON_5
The tag of Mouse button 5.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:284 | 
BUTTON_6
The tag of Mouse button 6.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:293 | 
BUTTON_7
The tag of Mouse button 7.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:302 | 
BUTTON_8
The tag of Mouse button 8.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:311 | 
type
The name of the event (case-sensitive), e.g. "click", "fire", or "submit".
| meta | description | 
|---|---|
| Type | String | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:43 | 
bubbles
Indicate whether the event bubbles up through the tree or not.
| meta | description | 
|---|---|
| Type | Boolean | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:51 | 
target
A reference to the target to which the event was originally dispatched.
| meta | description | 
|---|---|
| Type | Object | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:59 | 
currentTarget
A reference to the currently registered target for the event.
| meta | description | 
|---|---|
| Type | Object | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:67 | 
eventPhase
Indicates which phase of the event flow is currently being evaluated. Returns an integer value represented by 4 constants:
- Event.NONE = 0
- Event.CAPTURING_PHASE = 1
- Event.AT_TARGET = 2
- Event.BUBBLING_PHASE = 3 The phases are explained in the [section 3.1, Event dispatch and DOM event flow] (http://www.w3.org/TR/DOM-Level-3-Events/#event-flow), of the DOM Level 3 Events specification.
| meta | description | 
|---|---|
| Type | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:75 | 
Methods
setScrollData
Sets scroll data.
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:57 | 
Parameters
getScrollX
Returns the x axis scroll value.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:69 | 
getScrollY
Returns the y axis scroll value.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:79 | 
setLocation
Sets cursor location.
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:89 | 
Parameters
getLocation
Returns cursor location.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:101 | 
getLocationInView
Returns the current cursor location in screen coordinates.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:111 | 
getPreviousLocation
Returns the previous touch location.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:126 | 
getDelta
Returns the delta distance from the previous location to current location.
| meta | description | 
|---|---|
| Returns | Vec2 | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:136 | 
getDeltaX
Returns the X axis delta distance from the previous location to current location.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:146 | 
getDeltaY
Returns the Y axis delta distance from the previous location to current location.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:156 | 
setButton
Sets mouse button.
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:166 | 
Parameters
- buttonNumber
getButton
Returns mouse button.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:176 | 
getLocationX
Returns location X axis data.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:186 | 
getLocationY
Returns location Y axis data.
| meta | description | 
|---|---|
| Returns | Number | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event-manager/CCEvent.js:196 | 
constructor
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:37 | 
Parameters
- typeString The name of the event (case-sensitive), e.g. "click", "fire", or "submit"
- bubblesBoolean A boolean indicating whether the event bubbles up through the tree or not
unuse
Reset the event for being stored in the object pool.
| meta | description | 
|---|---|
| Returns | String | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:110 | 
reuse
Reuse the event for being used again by the object pool.
| meta | description | 
|---|---|
| Returns | String | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:125 | 
stopPropagation
Stops propagation for current event.
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:136 | 
stopPropagationImmediate
Stops propagation for current event immediately, the event won't even be dispatched to the listeners attached in the current target.
| meta | description | 
|---|---|
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:145 | 
isStopped
Checks whether the event has been stopped.
| meta | description | 
|---|---|
| Returns | Boolean | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:155 | 
getCurrentTarget
    Gets current target of the event                                                            
    note: It only be available when the event listener is associated with node.                
         It returns 0 when the listener is associated with fixed priority.
| meta | description | 
|---|---|
| Returns | Node | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:165 | 
getType
Gets the event type.
| meta | description | 
|---|---|
| Returns | String | 
| Defined in | https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/event.js:180 | 
