From f5b81db4c25bece14ab74b428b9de2cae3d1bbef Mon Sep 17 00:00:00 2001 From: PP Date: Wed, 22 Aug 2018 14:47:29 +0800 Subject: [PATCH] hide editbox input onDisable when stayOnTop (#3129) --- cocos2d/core/components/editbox/CCEditBox.js | 8 ++++++++ .../core/components/editbox/CCEditBoxImpl.js | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/cocos2d/core/components/editbox/CCEditBox.js b/cocos2d/core/components/editbox/CCEditBox.js index 61a2e93cc1..a5aad021e9 100644 --- a/cocos2d/core/components/editbox/CCEditBox.js +++ b/cocos2d/core/components/editbox/CCEditBox.js @@ -577,6 +577,14 @@ let EditBox = cc.Class({ this._impl.clear(); }, + onEnable () { + this._impl && this._impl.onEnable(); + }, + + onDisable () { + this._impl && this._impl.onDisable(); + }, + __preload () { if (!CC_EDITOR) { this._registerEvent(); diff --git a/cocos2d/core/components/editbox/CCEditBoxImpl.js b/cocos2d/core/components/editbox/CCEditBoxImpl.js index 3262874a0e..c0f328cc32 100644 --- a/cocos2d/core/components/editbox/CCEditBoxImpl.js +++ b/cocos2d/core/components/editbox/CCEditBoxImpl.js @@ -93,6 +93,25 @@ let EditBoxImpl = cc.Class({ this.__orientationChanged = null; }, + onEnable () { + if (!this._edTxt) { + return; + } + if (this._alwaysOnTop) { + this._edTxt.style.display = ''; + } + else { + this._edTxt.style.display = 'none'; + } + }, + + onDisable () { + if (!this._edTxt) { + return; + } + this._edTxt.style.display = 'none'; + }, + setTabIndex (index) { if (this._edTxt) { this._edTxt.tabIndex = index;