From 482fe0a040b20089ce44cfdd0281a3ca7baaad52 Mon Sep 17 00:00:00 2001 From: PP Date: Tue, 14 Aug 2018 15:48:41 +0800 Subject: [PATCH] fix editbox setFontColor for Editor (#3083) --- cocos2d/core/components/editbox/CCEditBox.js | 7 +++++++ cocos2d/core/components/editbox/CCEditBoxImpl.js | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cocos2d/core/components/editbox/CCEditBox.js b/cocos2d/core/components/editbox/CCEditBox.js index 97123d1511..61a2e93cc1 100644 --- a/cocos2d/core/components/editbox/CCEditBox.js +++ b/cocos2d/core/components/editbox/CCEditBox.js @@ -170,6 +170,9 @@ let EditBox = cc.Class({ if (this._textLabel) { this._textLabel.fontSize = this.fontSize; } + if (this._impl) { + this._impl.setFontSize(this.fontSize); + } } }, @@ -198,8 +201,12 @@ let EditBox = cc.Class({ default: cc.Color.WHITE, notify () { if (this._textLabel) { + this._textLabel.node.opacity = this.fontColor.a; this._textLabel.node.color = this.fontColor; } + if (this._impl) { + this._impl.setFontColor(this.fontColor); + } } }, diff --git a/cocos2d/core/components/editbox/CCEditBoxImpl.js b/cocos2d/core/components/editbox/CCEditBoxImpl.js index c9a49cd7ed..3262874a0e 100644 --- a/cocos2d/core/components/editbox/CCEditBoxImpl.js +++ b/cocos2d/core/components/editbox/CCEditBoxImpl.js @@ -201,7 +201,7 @@ let EditBoxImpl = cc.Class({ setFontColor (color) { this._textColor = color; - this._edTxt.style.color = color.toHEX(); + this._edTxt.style.color = color.toCSS('rgba'); }, setSize (width, height) { @@ -479,7 +479,7 @@ function registerInputEventListener (tmpEdTxt, editBoxImpl, isTextarea) { cbs.focus = function () { this.style.fontSize = editBoxImpl._edFontSize + 'px'; - this.style.color = editBoxImpl._textColor.toCSS('#rrggbbaa'); + this.style.color = editBoxImpl._textColor.toCSS('rgba'); // When stayOnTop, input will swallow touch event if (editBoxImpl._alwaysOnTop) { editBoxImpl._editing = true;