diff --git a/cocos2d/core/components/CCEditBox.js b/cocos2d/core/components/CCEditBox.js index 082f5d1ba1..ed38bbe3f2 100644 --- a/cocos2d/core/components/CCEditBox.js +++ b/cocos2d/core/components/CCEditBox.js @@ -420,14 +420,10 @@ var EditBox = cc.Class({ this._createBackgroundSprite(); - if(this._useOriginalSize){ - if(CC_EDITOR) { - this.node.setContentSize(sgNode.getContentSize()); - } + if(this._useOriginalSize && CC_EDITOR){ + this.node.setContentSize(sgNode.getContentSize()); this._useOriginalSize = false; - } - - if(!this._useOriginalSize) { + } else { sgNode.setContentSize(this.node.getContentSize()); } diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index f11030f4f7..346e395b01 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -328,14 +328,10 @@ var Label = cc.Class({ sgNode.setLineHeight(this._lineHeight); sgNode.setString(this.string); sgNode.setFontFileOrFamily(this.file); - if(this._useOriginalSize){ - if(CC_EDITOR) { - this.node.setContentSize(sgNode.getContentSize()); - } + if(this._useOriginalSize && CC_EDITOR){ + this.node.setContentSize(sgNode.getContentSize()); this._useOriginalSize = false; - } - - if(!this._useOriginalSize) { + } else { sgNode.setContentSize(this.node.getContentSize()); } sgNode.setColor(this.node.color); diff --git a/jsb/jsb-editbox.js b/jsb/jsb-editbox.js index a503dae3ba..dadd0ccb98 100644 --- a/jsb/jsb-editbox.js +++ b/jsb/jsb-editbox.js @@ -42,6 +42,13 @@ cc.defineGetterSetter(_p, 'delegate', null, _p.setDelegate); cc.defineGetterSetter(_p, 'inputMode', null, _p.setInputMode); cc.defineGetterSetter(_p, 'returnType', null, _p.setReturnType); +_p._setMaxLength = _p.setMaxLength; +_p.setMaxLength = function(maxLength) { + if (maxLength == -1) { + maxLength = Number.MAX_VALUE; + } + this._setMaxLength(maxLength); +} _p.editBoxEditingDidBegin = function (sender) { this.editBoxEditingDidBegan(sender);