1 /****************************************************************************
  2  Copyright (c) 2011-2012 cocos2d-x.org
  3  Copyright (c) 2013-2014 Chukong Technologies Inc.
  4  Copyright (c) 2012 James Chen
  5 
  6  http://www.cocos2d-x.org
  7 
  8  Permission is hereby granted, free of charge, to any person obtaining a copy
  9  of this software and associated documentation files (the "Software"), to deal
 10  in the Software without restriction, including without limitation the rights
 11  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 12  copies of the Software, and to permit persons to whom the Software is
 13  furnished to do so, subject to the following conditions:
 14 
 15  The above copyright notice and this permission notice shall be included in
 16  all copies or substantial portions of the Software.
 17 
 18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 19  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 20  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 21  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 22  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 24  THE SOFTWARE.
 25  ****************************************************************************/
 26 
 27 /**
 28  * @constant
 29  * @type Number
 30  */
 31 cc.KEYBOARD_RETURNTYPE_DEFAULT = 0;
 32 
 33 /**
 34  * @constant
 35  * @type Number
 36  */
 37 cc.KEYBOARD_RETURNTYPE_DONE = 1;
 38 
 39 /**
 40  * @constant
 41  * @type Number
 42  */
 43 cc.KEYBOARD_RETURNTYPE_SEND = 2;
 44 
 45 /**
 46  * @constant
 47  * @type Number
 48  */
 49 cc.KEYBOARD_RETURNTYPE_SEARCH = 3;
 50 
 51 /**
 52  * @constant
 53  * @type Number
 54  */
 55 cc.KEYBOARD_RETURNTYPE_GO = 4;
 56 
 57 /**
 58  * The EditBoxInputMode defines the type of text that the user is allowed * to enter.
 59  * @constant
 60  * @type Number
 61  */
 62 cc.EDITBOX_INPUT_MODE_ANY = 0;
 63 
 64 /**
 65  * The user is allowed to enter an e-mail address.
 66  * @constant
 67  * @type Number
 68  */
 69 cc.EDITBOX_INPUT_MODE_EMAILADDR = 1;
 70 
 71 /**
 72  * The user is allowed to enter an integer value.
 73  * @constant
 74  * @type Number
 75  */
 76 cc.EDITBOX_INPUT_MODE_NUMERIC = 2;
 77 
 78 /**
 79  * The user is allowed to enter a phone number.
 80  * @constant
 81  * @type Number
 82  */
 83 cc.EDITBOX_INPUT_MODE_PHONENUMBER = 3;
 84 
 85 /**
 86  * The user is allowed to enter a URL.
 87  * @constant
 88  * @type Number
 89  */
 90 cc.EDITBOX_INPUT_MODE_URL = 4;
 91 
 92 /**
 93  * The user is allowed to enter a real number value.
 94  * This extends kEditBoxInputModeNumeric by allowing a decimal point.
 95  * @constant
 96  * @type Number
 97  */
 98 cc.EDITBOX_INPUT_MODE_DECIMAL = 5;
 99 
100 /**
101  * The user is allowed to enter any text, except for line breaks.
102  * @constant
103  * @type Number
104  */
105 cc.EDITBOX_INPUT_MODE_SINGLELINE = 6;
106 
107 /**
108  * Indicates that the text entered is confidential data that should be
109  * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
110  * @constant
111  * @type Number
112  */
113 cc.EDITBOX_INPUT_FLAG_PASSWORD = 0;
114 
115 /**
116  * Indicates that the text entered is sensitive data that the
117  * implementation must never store into a dictionary or table for use
118  * in predictive, auto-completing, or other accelerated input schemes.
119  * A credit card number is an example of sensitive data.
120  * @constant
121  * @type Number
122  */
123 cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1;
124 
125 /**
126  * This flag is a hint to the implementation that during text editing,
127  * the initial letter of each word should be capitalized.
128  * @constant
129  * @type Number
130  */
131 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2;
132 
133 /**
134  * This flag is a hint to the implementation that during text editing,
135  * the initial letter of each sentence should be capitalized.
136  * @constant
137  * @type Number
138  */
139 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3;
140 
141 /**
142  * Capitalize all characters automatically.
143  * @constant
144  * @type Number
145  */
146 cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4;
147 
148 cc.EditBoxDelegate = cc.Class.extend({
149     /**
150      * This method is called when an edit box gains focus after keyboard is shown.
151      * @param {cc.EditBox} sender
152      */
153     editBoxEditingDidBegin: function (sender) {
154     },
155 
156     /**
157      * This method is called when an edit box loses focus after keyboard is hidden.
158      * @param {cc.EditBox} sender
159      */
160     editBoxEditingDidEnd: function (sender) {
161     },
162 
163     /**
164      * This method is called when the edit box text was changed.
165      * @param {cc.EditBox} sender
166      * @param {String} text
167      */
168     editBoxTextChanged: function (sender, text) {
169     },
170 
171     /**
172      * This method is called when the return button was pressed or the outside area of keyboard was touched.
173      * @param {cc.EditBox} sender
174      */
175     editBoxReturn: function (sender) {
176     }
177 });
178 
179 /**
180  * <p>cc.EditBox is a brief Class for edit box.<br/>
181  * You can use this widget to gather small amounts of text from the user.</p>
182  *
183  * @class
184  * @extends cc.ControlButton
185  *
186  * @property {String}   string                  - Content string of edit box
187  * @property {String}   maxLength               - Max length of the content string
188  * @property {String}   font                    - <@writeonly> Config font of edit box
189  * @property {String}   fontName                - <@writeonly> Config font name of edit box
190  * @property {Number}   fontSize                - <@writeonly> Config font size of edit box
191  * @property {cc.Color} fontColor               - <@writeonly> Config font color of edit box
192  * @property {String}   placeHolder             - Place holder of edit box
193  * @property {String}   placeHolderFont         - <@writeonly> Config font of place holder
194  * @property {String}   placeHolderFontName     - <@writeonly> Config font name of place holder
195  * @property {Number}   placeHolderFontSize     - <@writeonly> Config font size of place holder
196  * @property {cc.Color} placeHolderFontColor    - <@writeonly> Config font color of place holder
197  * @property {Number}   inputFlag               - <@writeonly> Input flag of edit box, one of the EditBoxInputFlag constants. e.g.cc.EDITBOX_INPUT_FLAG_PASSWORD
198  * @property {Object}   delegate                - <@writeonly> Delegate of edit box
199  * @property {Number}   inputMode               - <@writeonly> Input mode of the edit box. Value should be one of the EditBoxInputMode constants.
200  * @property {Number}   returnType              - <@writeonly> Return type of edit box, value should be one of the KeyboardReturnType constants.
201  *
202  */
203 cc.EditBox = cc.ControlButton.extend({
204     _domInputSprite: null,
205 
206     _delegate: null,
207     _editBoxInputMode: cc.EDITBOX_INPUT_MODE_ANY,
208     _editBoxInputFlag: cc.EDITBOX_INPUT_FLAG_SENSITIVE,
209     _keyboardReturnType: cc.KEYBOARD_RETURNTYPE_DEFAULT,
210 
211     _text: "",
212     _placeholderText: "",
213     _textColor: null,
214     _placeholderColor: null,
215     _maxLength: 50,
216     _adjustHeight: 18,
217 
218     _edTxt: null,
219     _edFontSize: 14,
220     _edFontName: "Arial",
221 
222     _placeholderFontName: "",
223     _placeholderFontSize: 14,
224 
225     _tooltip: false,
226     _className: "EditBox",
227 
228     /**
229      * * Constructor.
230      * */
231     ctor: function (boxSize) {
232         cc.ControlButton.prototype.ctor.call(this);
233 
234         this._textColor = cc.color.WHITE;
235         this._placeholderColor = cc.color.GRAY;
236         this.setContentSize(boxSize);
237         var tmpDOMSprite = this._domInputSprite = new cc.Sprite();
238         tmpDOMSprite.draw = function () {
239         };                           //redefine draw function
240         this.addChild(tmpDOMSprite);
241         var selfPointer = this;
242         var tmpEdTxt = this._edTxt = cc.newElement("input");
243         tmpEdTxt.type = "text";
244         tmpEdTxt.style.fontSize = this._edFontSize + "px";
245         tmpEdTxt.style.color = "#000000";
246         tmpEdTxt.style.border = 0;
247         tmpEdTxt.style.background = "transparent";
248         //tmpEdTxt.style.paddingLeft = "2px";
249         tmpEdTxt.style.width = "100%";
250         tmpEdTxt.style.height = "100%";
251         tmpEdTxt.style.active = 0;
252         tmpEdTxt.style.outline = "medium";
253         var onCanvasClick = function() {
254             tmpEdTxt.blur();
255         };
256         
257         // TODO the event listener will be remove when EditBox removes from parent.
258         cc._addEventListener(tmpEdTxt, "input", function () {
259             if (selfPointer._delegate && selfPointer._delegate.editBoxTextChanged)
260                 selfPointer._delegate.editBoxTextChanged(selfPointer, this.value);
261         });
262         cc._addEventListener(tmpEdTxt, "keypress", function (e) {
263             if (e.keyCode === cc.KEY.enter) {
264                 e.stopPropagation();
265                 e.preventDefault();
266                 cc._canvas.focus();
267             }
268         });
269         cc._addEventListener(tmpEdTxt, "focus", function () {
270             if (this.value == selfPointer._placeholderText) {
271                 this.value = "";
272                 this.style.fontSize = selfPointer._edFontSize + "px";
273                 this.style.color = cc.colorToHex(selfPointer._textColor);
274             }
275             if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidBegin)
276                 selfPointer._delegate.editBoxEditingDidBegin(selfPointer);
277             cc._addEventListener(cc._canvas, "click", onCanvasClick);
278         });
279         cc._addEventListener(tmpEdTxt, "blur", function () {
280             if (this.value == "") {
281                 this.value = selfPointer._placeholderText;
282                 this.style.fontSize = selfPointer._placeholderFontSize + "px";
283                 this.style.color = cc.colorToHex(selfPointer._placeholderColor);
284             }
285             if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidEnd)
286                 selfPointer._delegate.editBoxEditingDidEnd(selfPointer);
287             if (selfPointer._delegate && selfPointer._delegate.editBoxReturn)
288                 selfPointer._delegate.editBoxReturn(selfPointer);
289             cc._canvas.removeEventListener('click', onCanvasClick);
290         });
291 
292         cc.DOM.convert(tmpDOMSprite);
293         tmpDOMSprite.dom.appendChild(tmpEdTxt);
294         tmpDOMSprite.dom.showTooltipDiv = false;
295         tmpDOMSprite.dom.style.width = (boxSize.width - 6) + "px";
296         tmpDOMSprite.dom.style.height = (boxSize.height - 6) + "px";
297 
298         //this._domInputSprite.dom.style.borderWidth = "1px";
299         //this._domInputSprite.dom.style.borderStyle = "solid";
300         //this._domInputSprite.dom.style.borderRadius = "8px";
301         tmpDOMSprite.canvas.remove();
302     },
303 
304     /**
305      * Set the font.
306      * @param {String} fontName  The font name.
307      * @param {Number} fontSize  The font size.
308      */
309     setFont: function (fontName, fontSize) {
310         this._edFontSize = fontSize;
311         this._edFontName = fontName;
312         this._setFontToEditBox();
313     },
314 
315     _setFont: function (fontStyle) {
316         var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
317         if (res) {
318             this._edFontSize = parseInt(res[1]);
319             this._edFontName = res[2];
320             this._setFontToEditBox();
321         }
322     },
323 
324     /**
325      * set fontName
326      * @param {String} fontName
327      */
328     setFontName: function (fontName) {
329         this._edFontName = fontName;
330         this._setFontToEditBox();
331     },
332 
333     /**
334      * set fontSize
335      * @param {Number} fontSize
336      */
337     setFontSize: function (fontSize) {
338         this._edFontSize = fontSize;
339         this._setFontToEditBox();
340     },
341 
342     _setFontToEditBox: function () {
343         if (this._edTxt.value != this._placeholderText) {
344             this._edTxt.style.fontFamily = this._edFontName;
345             this._edTxt.style.fontSize = this._edFontSize + "px";
346         }
347     },
348 
349     /**
350      *  Set the text entered in the edit box.
351      * @deprecated
352      * @param {string} text The given text.
353      */
354     setText: function (text) {
355         cc.log("Please use the setString");
356         if (text != null) {
357             if (text == "") {
358                 this._edTxt.value = this._placeholderText;
359                 this._edTxt.style.color = cc.colorToHex(this._placeholderColor);
360             } else {
361                 this._edTxt.value = text;
362                 this._edTxt.style.color = cc.colorToHex(this._textColor);
363             }
364         }
365     },
366 
367     /**
368      *  Set the text entered in the edit box.
369      * @param {string} text The given text.
370      */
371     setString: function (text) {
372         if (text != null) {
373             if (text == "") {
374                 this._edTxt.value = this._placeholderText;
375                 this._edTxt.style.color = cc.colorToHex(this._placeholderColor);
376             } else {
377                 this._edTxt.value = text;
378                 this._edTxt.style.color = cc.colorToHex(this._textColor);
379             }
380         }
381     },
382 
383     /**
384      * Set the font color of the widget's text.
385      * @param {cc.Color} color
386      */
387     setFontColor: function (color) {
388         this._textColor = color;
389         if (this._edTxt.value != this._placeholderText) {
390             this._edTxt.style.color = cc.colorToHex(color);
391         }
392     },
393 
394     /**
395      * <p>
396      * Sets the maximum input length of the edit box. <br/>
397      * Setting this value enables multiline input mode by default.
398      * </p>
399      * @param {Number} maxLength The maximum length.
400      */
401     setMaxLength: function (maxLength) {
402         if (!isNaN(maxLength) && maxLength > 0) {
403             this._maxLength = maxLength;
404             this._edTxt.maxLength = maxLength;
405         }
406     },
407 
408     /**
409      * Gets the maximum input length of the edit box.
410      * @return {Number} Maximum input length.
411      */
412     getMaxLength: function () {
413         return this._maxLength;
414     },
415 
416     /**
417      * Set a text in the edit box that acts as a placeholder when an edit box is empty.
418      * @param {string} text The given text.
419      */
420     setPlaceHolder: function (text) {
421         if (text != null) {
422             var oldPlaceholderText = this._placeholderText;
423             this._placeholderText = text;
424             if (this._edTxt.value == oldPlaceholderText) {
425                 this._edTxt.value = text;
426                 this._edTxt.style.color = cc.colorToHex(this._placeholderColor);
427                 this._setPlaceholderFontToEditText();
428             }
429         }
430     },
431 
432     /**
433      * Set the placeholder's font.
434      * @param {String} fontName
435      * @param {Number} fontSize
436      */
437     setPlaceholderFont: function (fontName, fontSize) {
438         this._placeholderFontName = fontName;
439         this._placeholderFontSize = fontSize;
440         this._setPlaceholderFontToEditText();
441     },
442     _setPlaceholderFont: function (fontStyle) {
443         var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
444         if (res) {
445             this._placeholderFontName = res[2];
446             this._placeholderFontSize = parseInt(res[1]);
447             this._setPlaceholderFontToEditText();
448         }
449     },
450 
451     /**
452      * Set the placeholder's fontName.
453      * @param {String} fontName
454      */
455     setPlaceholderFontName: function (fontName) {
456         this._placeholderFontName = fontName;
457         this._setPlaceholderFontToEditText();
458     },
459 
460     /**
461      * Set the placeholder's fontSize.
462      * @param {Number} fontSize
463      */
464     setPlaceholderFontSize: function (fontSize) {
465         this._placeholderFontSize = fontSize;
466         this._setPlaceholderFontToEditText();
467     },
468 
469     _setPlaceholderFontToEditText: function () {
470         if (this._edTxt.value == this._placeholderText) {
471             this._edTxt.style.fontFamily = this._placeholderFontName;
472             this._edTxt.style.fontSize = this._placeholderFontSize + "px";
473         }
474     },
475 
476     /**
477      * Set the font color of the placeholder text when the edit box is empty.
478      * @param {cc.Color} color
479      */
480     setPlaceholderFontColor: function (color) {
481         this._placeholderColor = color;
482         if (this._edTxt.value == this._placeholderText) {
483             this._edTxt.style.color = cc.colorToHex(color);
484         }
485     },
486 
487     /**
488      * Set the input flags that are to be applied to the edit box.
489      * @param {Number} inputFlag One of the EditBoxInputFlag constants.
490      * e.g.cc.EDITBOX_INPUT_FLAG_PASSWORD
491      */
492     setInputFlag: function (inputFlag) {
493         this._editBoxInputFlag = inputFlag;
494         if (inputFlag == cc.EDITBOX_INPUT_FLAG_PASSWORD)
495             this._edTxt.type = "password";
496         else
497             this._edTxt.type = "text";
498     },
499 
500     /**
501      * Gets the  input string of the edit box.
502      * @deprecated
503      * @return {string}
504      */
505     getText: function () {
506         cc.log("Please use the getString");
507         return this._edTxt.value;
508     },
509 
510     /**
511      * Gets the  input string of the edit box.
512      * @return {string}
513      */
514     getString: function () {
515         return this._edTxt.value;
516     },
517 
518     /**
519      * Init edit box with specified size.
520      * @param {cc.Size} size
521      * @param {cc.Color | cc.Scale9Sprite} normal9SpriteBg
522      */
523     initWithSizeAndBackgroundSprite: function (size, normal9SpriteBg) {
524         if (this.initWithBackgroundSprite(normal9SpriteBg)) {
525             this._domInputSprite.x = 3;
526             this._domInputSprite.y = 3;
527 
528             this.setZoomOnTouchDown(false);
529             this.setPreferredSize(size);
530             this.x = 0;
531             this.y = 0;
532             this._addTargetWithActionForControlEvent(this, this.touchDownAction, cc.CONTROL_EVENT_TOUCH_UP_INSIDE);
533             return true;
534         }
535         return false;
536     },
537 
538     /* override functions */
539     /**
540      * Set the delegate for edit box.
541      */
542     setDelegate: function (delegate) {
543         this._delegate = delegate;
544     },
545 
546     /**
547      * Get a text in the edit box that acts as a placeholder when an
548      * edit box is empty.
549      * @return {String}
550      */
551     getPlaceHolder: function () {
552         return this._placeholderText;
553     },
554 
555     /**
556      * Set the input mode of the edit box.
557      * @param {Number} inputMode One of the EditBoxInputMode constants.
558      */
559     setInputMode: function (inputMode) {
560         this._editBoxInputMode = inputMode;
561     },
562 
563     /**
564      * Set the return type that are to be applied to the edit box.
565      * @param {Number} returnType One of the CCKeyboardReturnType constants.
566      */
567     setReturnType: function (returnType) {
568         this._keyboardReturnType = returnType;
569     },
570 
571     keyboardWillShow: function (info) {
572         var rectTracked = cc.EditBox.getRect(this);
573         // some adjustment for margin between the keyboard and the edit box.
574         rectTracked.y -= 4;
575         // if the keyboard area doesn't intersect with the tracking node area, nothing needs to be done.
576         if (!rectTracked.intersectsRect(info.end)) {
577             cc.log("needn't to adjust view layout.");
578             return;
579         }
580 
581         // assume keyboard at the bottom of screen, calculate the vertical adjustment.
582         this._adjustHeight = info.end.getMaxY() - rectTracked.getMinY();
583         // CCLOG("CCEditBox:needAdjustVerticalPosition(%f)", m_fAdjustHeight);
584 
585         //callback
586     },
587     keyboardDidShow: function (info) {
588     },
589     keyboardWillHide: function (info) {
590         //if (m_pEditBoxImpl != NULL) {
591         //    m_pEditBoxImpl->doAnimationWhenKeyboardMove(info.duration, -m_fAdjustHeight);
592         //}
593     },
594     keyboardDidHide: function (info) {
595     },
596 
597     touchDownAction: function (sender, controlEvent) {
598         //this._editBoxImpl.openKeyboard();
599     },
600 
601     //HTML5 Only
602     initWithBackgroundColor: function (size, bgColor) {
603         this._edWidth = size.width;
604         this.dom.style.width = this._edWidth.toString() + "px";
605         this._edHeight = size.height;
606         this.dom.style.height = this._edHeight.toString() + "px";
607         this.dom.style.backgroundColor = cc.colorToHex(bgColor);
608     }
609 });
610 
611 var _p = cc.EditBox.prototype;
612 
613 // Extended properties
614 /** @expose */
615 _p.font;
616 cc.defineGetterSetter(_p, "font", null, _p._setFont);
617 /** @expose */
618 _p.fontName;
619 cc.defineGetterSetter(_p, "fontName", null, _p.setFontName);
620 /** @expose */
621 _p.fontSize;
622 cc.defineGetterSetter(_p, "fontSize", null, _p.setFontSize);
623 /** @expose */
624 _p.fontColor;
625 cc.defineGetterSetter(_p, "fontColor", null, _p.setFontColor);
626 /** @expose */
627 _p.string;
628 cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
629 /** @expose */
630 _p.maxLength;
631 cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength);
632 /** @expose */
633 _p.placeHolder;
634 cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder);
635 /** @expose */
636 _p.placeHolderFont;
637 cc.defineGetterSetter(_p, "placeHolderFont", null, _p._setPlaceholderFont);
638 /** @expose */
639 _p.placeHolderFontName;
640 cc.defineGetterSetter(_p, "placeHolderFontName", null, _p.setPlaceholderFontName);
641 /** @expose */
642 _p.placeHolderFontSize;
643 cc.defineGetterSetter(_p, "placeHolderFontSize", null, _p.setPlaceholderFontSize);
644 /** @expose */
645 _p.placeHolderFontColor;
646 cc.defineGetterSetter(_p, "placeHolderFontColor", null, _p.setPlaceholderFontColor);
647 /** @expose */
648 _p.inputFlag;
649 cc.defineGetterSetter(_p, "inputFlag", null, _p.setInputFlag);
650 /** @expose */
651 _p.delegate;
652 cc.defineGetterSetter(_p, "delegate", null, _p.setDelegate);
653 /** @expose */
654 _p.inputMode;
655 cc.defineGetterSetter(_p, "inputMode", null, _p.setInputMode);
656 /** @expose */
657 _p.returnType;
658 cc.defineGetterSetter(_p, "returnType", null, _p.setReturnType);
659 
660 _p = null;
661 
662 cc.EditBox.getRect = function (node) {
663     var contentSize = node.getContentSize();
664     var rect = cc.rect(0, 0, contentSize.width, contentSize.height);
665     return cc.RectApplyAffineTransform(rect, node.nodeToWorldTransform());
666 };
667 
668 /**
669  * create a edit box with size and background-color or
670  * @param {cc.Size} size
671  * @param {cc.Scale9Sprite } normal9SpriteBg
672  * @param {cc.Scale9Sprite } [press9SpriteBg]
673  * @param {cc.Scale9Sprite } [disabled9SpriteBg]
674  */
675 cc.EditBox.create = function (size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) {
676     var edbox = new cc.EditBox(size);
677     if (edbox.initWithSizeAndBackgroundSprite(size, normal9SpriteBg)) {
678         if (press9SpriteBg)
679             edbox.setBackgroundSpriteForState(press9SpriteBg, cc.CONTROL_STATE_HIGHLIGHTED);
680 
681         if (disabled9SpriteBg)
682             edbox.setBackgroundSpriteForState(disabled9SpriteBg, cc.CONTROL_STATE_DISABLED);
683     }
684     return edbox;
685 };
686 
687 
688 
689 
690