Class: InputSystem
输入系统(管理鼠标信息和状态)
Hierarchy
↳
InputSystem
Table of contents
Constructors
Properties
- button
- buttons
- distanceRatio
- dropTarget
- dx
- dy
- event
- idleTimeout
- isDragEnd
- isDragStart
- isDraging
- isIdle
- isMouseDown
- isMouseOn
- mouseDownX
- mouseDownY
- mouseoverTarget
- previous
- skipPointerMovePicking
- stage
- target
- touchesDistance
- type
- wheelZoom
- x
- y
Accessors
Methods
- _initEvent
- addEventListener
- dispatchEvent
- hasListener
- isRightButton
- mockMouseEvent
- on
- preventDefault
- removeEventListener
- updateBaseInfo
- updateMouseInfo
- updateTouchInfo
Constructors
constructor
new InputSystem()
Overrides
Properties
button
button: number
= 0
buttons
buttons: number
= 0
distanceRatio
distanceRatio: number
= 1
dropTarget
dropTarget: DisplayObject
当前拖拽时的目标对象
dx
dx: number
相对于上一次鼠标x的移动增量(canvas坐标)
dy
dy: number
相对于上一次鼠标y的移动增量(canvas坐标)
event
event: MouseEvent
原始的事件对象
idleTimeout
idleTimeout: number
= 50
鼠标空闲时间, 50毫秒内没有动作时认为空闲
isDragEnd
isDragEnd: boolean
= false
是否拖拽结束
isDragStart
isDragStart: boolean
= false
是否拖拽的开始
isDraging
isDraging: boolean
= false
是否在拖拽中
isIdle
isIdle: boolean
鼠标是否空闲
isMouseDown
isMouseDown: boolean
= false
鼠标是否按下
isMouseOn
isMouseOn: boolean
= false
鼠标是否在画布上
mouseDownX
mouseDownX: number
= 0
鼠标按下时的坐标(canvas坐标)
mouseDownY
mouseDownY: number
= 0
鼠标松开时的坐标(canvas坐标)
mouseoverTarget
mouseoverTarget: DisplayObject
当前鼠标指向的对象
previous
previous: any
上一次事件的状态记录
skipPointerMovePicking
skipPointerMovePicking: boolean
= false
忽略将提高性能、降低能耗
对象不再触发和响应 mousemove、mouseenter、mouseout事件
stage
stage: Stage
target
Optional
target: DisplayObject
当前鼠标选中的对象
touchesDistance
touchesDistance: number
= 0
type
type: string
wheelZoom
wheelZoom: boolean
= true
鼠标缩放开关,为false时,鼠标缩放将不起作用
x
x: number
= -1
鼠标的屏幕坐标x(canvas左上角为0,0)
y
y: number
= -1
鼠标的屏幕坐标y(canvas左上角为0,0)
Accessors
pickedObject
get
pickedObject(): DisplayObject
当前鼠标选中的对象, 已过时,使用 target 替代,例如:stage.inputSystem.target
Deprecated
Returns
Methods
_initEvent
_initEvent(stage
): void
Parameters
Name | Type |
---|---|
stage | any |
Returns
void
addEventListener
addEventListener(type
, callback
): void
增加事件监听
Parameters
Name | Type | Description |
---|---|---|
type | string | 事件类型 |
callback | Function |
Returns
void
Inherited from
dispatchEvent
dispatchEvent(event
): void
分发事件
Parameters
Name | Type |
---|---|
event | any |
Returns
void
Inherited from
hasListener
hasListener(type
): boolean
是否有该类型的监听
Parameters
Name | Type |
---|---|
type | string |
Returns
boolean
Inherited from
isRightButton
isRightButton(): boolean
是否右键
Returns
boolean
mockMouseEvent
mockMouseEvent(canvas
, type
, x
, y
): void
Parameters
Name | Type |
---|---|
canvas | any |
type | any |
x | any |
y | any |
Returns
void
on
on(type
, callback
): void
增加监听事件, 功能完全等同于addEventListener,一种简写
Parameters
Name | Type | Description |
---|---|---|
type | string | 事件类型 |
callback | Function | 事件处理函数 |
Returns
void
Inherited from
preventDefault
preventDefault(): void
已过时,请使用:inputSystem.event.preventDefault()
Deprecated
Returns
void
removeEventListener
removeEventListener(type
, callback
): any
移除一个事件监听
Parameters
Name | Type |
---|---|
type | string |
callback | Function |
Returns
any
Inherited from
EventTarget.removeEventListener
updateBaseInfo
updateBaseInfo(event
, type
): void
Parameters
Name | Type |
---|---|
event | any |
type | string |
Returns
void
updateMouseInfo
updateMouseInfo(mouseEvent
, type
): void
Parameters
Name | Type |
---|---|
mouseEvent | MouseEvent |
type | string |
Returns
void
updateTouchInfo
updateTouchInfo(event
, type
): void
Parameters
Name | Type |
---|---|
event | TouchEvent |
type | string |
Returns
void