From ba74d95fb18a8f4234de379e245a797c27f3bc08 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 14 Mar 2016 10:35:11 +0800 Subject: [PATCH 1/2] improve button interactable behavior --- cocos2d/core/components/CCButton.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js index 90668f4e5e..d2e0b9289c 100644 --- a/cocos2d/core/components/CCButton.js +++ b/cocos2d/core/components/CCButton.js @@ -314,6 +314,7 @@ var Button = cc.Class({ }, _onTouchMove: function (event) { + if (!this.interactable || !this.enabledInHierarchy) return; // mobile phone will not emit _onMouseMoveOut, // so we have to do hit test when touch moving var touch = event.touch; @@ -331,6 +332,8 @@ var Button = cc.Class({ }, _onTouchEnded: function () { + if (!this.interactable || !this.enabledInHierarchy) return; + if (this._pressed) { cc.Component.EventHandler.emitEvents(this.clickEvents); } @@ -339,6 +342,8 @@ var Button = cc.Class({ }, _onTouchCancel: function () { + if (!this.interactable || !this.enabledInHierarchy) return; + this._pressed = false; this._updateState(); }, From 4009c9a7a94c88a30ba45de136f1e15a5847a421 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 14 Mar 2016 10:43:13 +0800 Subject: [PATCH 2/2] fix scrollview mouse wheel event --- cocos2d/core/components/CCScrollView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index 700017365e..34ebac6605 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -473,8 +473,8 @@ var ScrollView = cc.Class({ if(!this._stopMouseWheel) { this._handlePressLogic(); + this.schedule(this._checkMouseWheel, 0.01); this._stopMouseWheel = true; - this._checkMouseWheel(); } event.stopPropagation(); }, @@ -484,6 +484,7 @@ var ScrollView = cc.Class({ if (!cc.pFuzzyEqual(currentOutOfBoundary, cc.p(0, 0), EPSILON)) { this._processInertiaScroll(); + this.unschedule(this._checkMouseWheel); this._stopMouseWheel = false; } },