diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js index 61f71711ca..19414c0af2 100644 --- a/cocos2d/core/components/CCButton.js +++ b/cocos2d/core/components/CCButton.js @@ -643,3 +643,13 @@ var Button = cc.Class({ }); cc.Button = module.exports = Button; + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event click + * @param {Event} event + * @param {Button} event.detail - The Button component. + */ diff --git a/cocos2d/core/components/CCEditBox.js b/cocos2d/core/components/CCEditBox.js index dbf804fc31..902a3b90b3 100644 --- a/cocos2d/core/components/CCEditBox.js +++ b/cocos2d/core/components/CCEditBox.js @@ -500,18 +500,22 @@ var EditBox = cc.Class({ editBoxEditingDidBegan: function() { cc.Component.EventHandler.emitEvents(this.editingDidBegan, this); + this.node.emit('editing-did-began', this); }, editBoxEditingDidEnded: function() { cc.Component.EventHandler.emitEvents(this.editingDidEnded, this); + this.node.emit('editing-did-ended', this); }, editBoxTextChanged: function(editBox, text) { cc.Component.EventHandler.emitEvents(this.textChanged, text, this); + this.node.emit('text-changed', this); }, editBoxEditingReturn: function() { cc.Component.EventHandler.emitEvents(this.editingReturn, this); + this.node.emit('editing-return', this); }, __preload: function() { @@ -582,3 +586,43 @@ if(CC_JSB) { } cc.EditBox = module.exports = EditBox; + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event editing-did-began + * @param {Event} event + * @param {EditBox} event.detail - The EditBox component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event editing-did-ended + * @param {Event} event + * @param {EditBox} event.detail - The EditBox component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event text-changed + * @param {Event} event + * @param {EditBox} event.detail - The EditBox component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event editing-return + * @param {Event} event + * @param {EditBox} event.detail - The EditBox component. + */ diff --git a/cocos2d/core/components/CCPageView.js b/cocos2d/core/components/CCPageView.js index d8267c575f..d3af08a70f 100644 --- a/cocos2d/core/components/CCPageView.js +++ b/cocos2d/core/components/CCPageView.js @@ -371,6 +371,7 @@ var PageView = cc.Class({ if (this._lastPageIdx === this._curPageIdx) return; this._lastPageIdx = this._curPageIdx; cc.Component.EventHandler.emitEvents(this.pageEvents, this, EventType.PAGE_TURNING); + this.node.emit('page-turning', this); }, // 是否超过自动滚动临界值 @@ -451,3 +452,13 @@ var PageView = cc.Class({ }); cc.PageView = module.exports = PageView; + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event page-turning + * @param {Event} event + * @param {PageView} event.detail - The PageView component. + */ diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index e8dc343582..ecb288d7c1 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -1441,3 +1441,113 @@ var ScrollView = cc.Class({ }); cc.ScrollView = module.exports = ScrollView; + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event scroll-to-top + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event scroll-to-bottom + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event scroll-to-left + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event scroll-to-right + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event scrolling + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event bounce-bottom + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event bounce-top + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event bounce-left + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event bounce-right + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event scroll-ended + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event touch-up + * @param {Event} event + * @param {ScrollView} event.detail - The ScrollView component. + */ diff --git a/cocos2d/core/components/CCSlider.js b/cocos2d/core/components/CCSlider.js index 81cb459201..3715326841 100644 --- a/cocos2d/core/components/CCSlider.js +++ b/cocos2d/core/components/CCSlider.js @@ -182,11 +182,12 @@ var Slider = cc.Class({ _handleSliderLogic: function (touch) { this._updateProgress(touch); - this._emitSldeEvent(); + this._emitSlideEvent(); }, - _emitSldeEvent: function () { + _emitSlideEvent: function () { cc.Component.EventHandler.emitEvents(this.slideEvents, this); + this.node.emit('slide', this); }, _updateProgress: function (touch) { @@ -219,3 +220,13 @@ var Slider = cc.Class({ }); cc.Slider = module.exports = Slider; + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event slider + * @param {Event} event + * @param {Slider} event.detail - The slider component. + */ diff --git a/cocos2d/core/components/CCToggle.js b/cocos2d/core/components/CCToggle.js index e7757393bc..d2cc248027 100644 --- a/cocos2d/core/components/CCToggle.js +++ b/cocos2d/core/components/CCToggle.js @@ -168,7 +168,7 @@ var Toggle = cc.Class({ }, _emitToggleEvents: function (event) { - this.node.emit('toggle-event', this); + this.node.emit('toggle', this); if(this.checkEvents) { cc.Component.EventHandler.emitEvents(this.checkEvents, event, this); } @@ -187,7 +187,7 @@ var Toggle = cc.Class({ } this.isChecked = true; - this.node.emit('toggle-event', this); + this.node.emit('toggle', this); if(this.toggleGroup) { this.toggleGroup.updateToggles(this); @@ -208,10 +208,20 @@ var Toggle = cc.Class({ this.isChecked = false; - this.node.emit('toggle-event', this); + this.node.emit('toggle', this); } }); cc.Toggle = module.exports = Toggle; + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event toggle + * @param {Event} event + * @param {Toggle} event.detail - The Toggle component. + */ diff --git a/cocos2d/core/components/CCVideoPlayer.js b/cocos2d/core/components/CCVideoPlayer.js index 52e83c431e..33730940ff 100644 --- a/cocos2d/core/components/CCVideoPlayer.js +++ b/cocos2d/core/components/CCVideoPlayer.js @@ -265,30 +265,37 @@ var VideoPlayer = cc.Class({ onReadyToPlay: function () { cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.READY_TO_PLAY); + this.node.emit('ready-to-play', this); }, onMetaLoaded: function () { cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.META_LOADED); + this.node.emit('meta-loaded', this); }, onClicked: function () { cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.CLICKED); + this.node.emit('clicked', this); }, onPlaying: function(){ cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.PLAYING); + this.node.emit('playing', this); }, onPasued: function() { cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.PAUSED); + this.node.emit('paused', this); }, onStopped: function() { cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.STOPPED); + this.node.emit('stopped', this); }, onCompleted: function() { cc.Component.EventHandler.emitEvents(this.videoPlayerEvent, this, EventType.COMPLETED); + this.node.emit('completed', this); }, /** @@ -360,3 +367,74 @@ var VideoPlayer = cc.Class({ }); cc.VideoPlayer = module.exports = VideoPlayer; + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event ready-to-play + * @param {Event} event + * @param {VideoPlayer} event.detail - The VideoPlayer component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event meta-loaded + * @param {Event} event + * @param {VideoPlayer} event.detail - The VideoPlayer component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event clicked + * @param {Event} event + * @param {VideoPlayer} event.detail - The VideoPlayer component. + */ + + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event playing + * @param {Event} event + * @param {VideoPlayer} event.detail - The VideoPlayer component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event paused + * @param {Event} event + * @param {VideoPlayer} event.detail - The VideoPlayer component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event stopped + * @param {Event} event + * @param {VideoPlayer} event.detail - The VideoPlayer component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event completed + * @param {Event} event + * @param {VideoPlayer} event.detail - The VideoPlayer component. + */ diff --git a/cocos2d/core/components/CCWebView.js b/cocos2d/core/components/CCWebView.js index aa639de9a1..41b853c1ba 100644 --- a/cocos2d/core/components/CCWebView.js +++ b/cocos2d/core/components/CCWebView.js @@ -139,17 +139,49 @@ var WebView = cc.Class({ _onWebViewLoaded: function () { cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.LOADED); + this.node.emit('loaded', this); }, _onWebViewLoading: function () { cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.LOADING); + this.node.emit('loading', this); return true; }, _onWebViewLoadError: function () { cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.ERROR); + this.node.emit('error', this); } }); cc.WebView = module.exports = WebView; +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event loaded + * @param {Event} event + * @param {WebView} event.detail - The WebView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event loading + * @param {Event} event + * @param {WebView} event.detail - The WebView component. + */ + +/** + * !#en + * Note: This event is emitted from the node to which the component belongs. + * !#zh + * 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。 + * @event error + * @param {Event} event + * @param {WebView} event.detail - The WebView component. + */