Component.EventHandler Class

Module: cc

Component will register a event to target component's handler. And it will trigger the handler when a certain event occurs.

!@zh “EventHandler” 类用来设置场景中的事件回调, 该类允许用户设置回调目标节点,目标组件名,组件方法名, 并可通过 emit 方法调用目标函数。

Index

Properties
Methods

Details

Properties

target

Event target

meta description
Type Node
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/components/CCComponentEventHandler.js:50
component

Component name

meta description
Type String
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/components/CCComponentEventHandler.js:61
handler

Event handler

meta description
Type String
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/components/CCComponentEventHandler.js:71
customEventData

Custom Event Data

meta description
Type String
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/components/CCComponentEventHandler.js:82

Methods

emitEvents
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/components/CCComponentEventHandler.js:95
Parameters
emit

Emit event with params

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/components/CCComponentEventHandler.js:119
Parameters
Examples
// Call Function
var eventHandler = new cc.Component.EventHandler();
eventHandler.target = newTarget;
eventHandler.component = "MainMenu";
eventHandler.handler = "OnClick"
eventHandler.emit(["param1", "param2", ....]);

results matching ""

    No results matching ""