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 /**
149  * @class
150  * @extends cc.Class
151  */
152 cc.EditBoxDelegate = cc.Class.extend({
153     /**
154      * This method is called when an edit box gains focus after keyboard is shown.
155      * @param {cc.EditBox} sender
156      */
157     editBoxEditingDidBegin: function (sender) {
158     },
159 
160     /**
161      * This method is called when an edit box loses focus after keyboard is hidden.
162      * @param {cc.EditBox} sender
163      */
164     editBoxEditingDidEnd: function (sender) {
165     },
166 
167     /**
168      * This method is called when the edit box text was changed.
169      * @param {cc.EditBox} sender
170      * @param {String} text
171      */
172     editBoxTextChanged: function (sender, text) {
173     },
174 
175     /**
176      * This method is called when the return button was pressed or the outside area of keyboard was touched.
177      * @param {cc.EditBox} sender
178      */
179     editBoxReturn: function (sender) {
180     }
181 });
182 
183 /**
184  * <p>cc.EditBox is a brief Class for edit box.<br/>
185  * You can use this widget to gather small amounts of text from the user.</p>
186  *
187  * @class
188  * @extends cc.ControlButton
189  *
190  * @property {String}   string                  - Content string of edit box
191  * @property {String}   maxLength               - Max length of the content string
192  * @property {String}   font                    - <@writeonly> Config font of edit box
193  * @property {String}   fontName                - <@writeonly> Config font name of edit box
194  * @property {Number}   fontSize                - <@writeonly> Config font size of edit box
195  * @property {cc.Color} fontColor               - <@writeonly> Config font color of edit box
196  * @property {String}   placeHolder             - Place holder of edit box
197  * @property {String}   placeHolderFont         - <@writeonly> Config font of place holder
198  * @property {String}   placeHolderFontName     - <@writeonly> Config font name of place holder
199  * @property {Number}   placeHolderFontSize     - <@writeonly> Config font size of place holder
200  * @property {cc.Color} placeHolderFontColor    - <@writeonly> Config font color of place holder
201  * @property {Number}   inputFlag               - <@writeonly> Input flag of edit box, one of the EditBoxInputFlag constants. e.g.cc.EDITBOX_INPUT_FLAG_PASSWORD
202  * @property {Object}   delegate                - <@writeonly> Delegate of edit box
203  * @property {Number}   inputMode               - <@writeonly> Input mode of the edit box. Value should be one of the EditBoxInputMode constants.
204  * @property {Number}   returnType              - <@writeonly> Return type of edit box, value should be one of the KeyboardReturnType constants.
205  *
206  */
207 cc.EditBox = cc.ControlButton.extend({
208     _domInputSprite: null,
209 
210     _delegate: null,
211     _editBoxInputMode: cc.EDITBOX_INPUT_MODE_ANY,
212     _editBoxInputFlag: cc.EDITBOX_INPUT_FLAG_SENSITIVE,
213     _keyboardReturnType: cc.KEYBOARD_RETURNTYPE_DEFAULT,
214 
215     _text: "",
216     _placeholderText: "",
217     _textColor: null,
218     _placeholderColor: null,
219     _maxLength: 50,
220     _adjustHeight: 18,
221 
222     _edTxt: null,
223     _edFontSize: 14,
224     _edFontName: "Arial",
225 
226     _placeholderFontName: "",
227     _placeholderFontSize: 14,
228 
229     _tooltip: false,
230     _className: "EditBox",
231 
232     /**
233      * constructor of cc.EditBox
234      * @param {cc.Size} size
235      * @param {cc.Scale9Sprite} normal9SpriteBg
236      * @param {cc.Scale9Sprite} press9SpriteBg
237      * @param {cc.Scale9Sprite} disabled9SpriteBg
238      */
239     ctor: function (size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) {
240         cc.ControlButton.prototype.ctor.call(this);
241 
242         this._textColor = cc.color.WHITE;
243         this._placeholderColor = cc.color.GRAY;
244         this.setContentSize(size);
245         var tmpDOMSprite = this._domInputSprite = new cc.Sprite();
246         tmpDOMSprite.draw = function () {};  //redefine draw function
247         this.addChild(tmpDOMSprite);
248         var selfPointer = this;
249         var tmpEdTxt = this._edTxt = cc.newElement("input");
250         tmpEdTxt.type = "text";
251         tmpEdTxt.style.fontSize = this._edFontSize + "px";
252         tmpEdTxt.style.color = "#000000";
253         tmpEdTxt.style.border = 0;
254         tmpEdTxt.style.background = "transparent";
255         //tmpEdTxt.style.paddingLeft = "2px";
256         tmpEdTxt.style.width = "100%";
257         tmpEdTxt.style.height = "100%";
258         tmpEdTxt.style.active = 0;
259         tmpEdTxt.style.outline = "medium";
260         tmpEdTxt.style.padding = "0";
261         var onCanvasClick = function() { tmpEdTxt.blur();};
262         
263         // TODO the event listener will be remove when EditBox removes from parent.
264         cc._addEventListener(tmpEdTxt, "input", function () {
265             if (selfPointer._delegate && selfPointer._delegate.editBoxTextChanged)
266                 selfPointer._delegate.editBoxTextChanged(selfPointer, this.value);
267         });
268         cc._addEventListener(tmpEdTxt, "keypress", function (e) {
269             if (e.keyCode === cc.KEY.enter) {
270                 e.stopPropagation();
271                 e.preventDefault();
272                 cc._canvas.focus();
273             }
274         });
275         cc._addEventListener(tmpEdTxt, "focus", function () {
276             if (this.value === selfPointer._placeholderText) {
277                 this.value = "";
278                 this.style.fontSize = selfPointer._edFontSize + "px";
279                 this.style.color = cc.colorToHex(selfPointer._textColor);
280                 if (selfPointer._editBoxInputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD)
281                     selfPointer._edTxt.type = "password";
282                 else
283                     selfPointer._edTxt.type = "text";
284             }
285             if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidBegin)
286                 selfPointer._delegate.editBoxEditingDidBegin(selfPointer);
287             cc._addEventListener(cc._canvas, "click", onCanvasClick);
288         });
289         cc._addEventListener(tmpEdTxt, "blur", function () {
290             if (this.value === "") {
291                 this.value = selfPointer._placeholderText;
292                 this.style.fontSize = selfPointer._placeholderFontSize + "px";
293                 this.style.color = cc.colorToHex(selfPointer._placeholderColor);
294                 selfPointer._edTxt.type = "text";
295             }
296             if (selfPointer._delegate && selfPointer._delegate.editBoxEditingDidEnd)
297                 selfPointer._delegate.editBoxEditingDidEnd(selfPointer);
298             if (selfPointer._delegate && selfPointer._delegate.editBoxReturn)
299                 selfPointer._delegate.editBoxReturn(selfPointer);
300             cc._canvas.removeEventListener('click', onCanvasClick);
301         });
302 
303         cc.DOM.convert(tmpDOMSprite);
304         tmpDOMSprite.dom.appendChild(tmpEdTxt);
305         tmpDOMSprite.dom.showTooltipDiv = false;
306         tmpDOMSprite.dom.style.width = (size.width - 6) + "px";
307         tmpDOMSprite.dom.style.height = (size.height - 6) + "px";
308 
309         //this._domInputSprite.dom.style.borderWidth = "1px";
310         //this._domInputSprite.dom.style.borderStyle = "solid";
311         //this._domInputSprite.dom.style.borderRadius = "8px";
312         tmpDOMSprite.canvas.remove();
313 
314         if (this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg)) {
315             if (press9SpriteBg)
316                 this.setBackgroundSpriteForState(press9SpriteBg, cc.CONTROL_STATE_HIGHLIGHTED);
317             if (disabled9SpriteBg)
318                 this.setBackgroundSpriteForState(disabled9SpriteBg, cc.CONTROL_STATE_DISABLED);
319         }
320     },
321 
322     /**
323      * Set the font.
324      * @param {String} fontName  The font name.
325      * @param {Number} fontSize  The font size.
326      */
327     setFont: function (fontName, fontSize) {
328         this._edFontSize = fontSize;
329         this._edFontName = fontName;
330         this._setFontToEditBox();
331     },
332 
333     _setFont: function (fontStyle) {
334         var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
335         if (res) {
336             this._edFontSize = parseInt(res[1]);
337             this._edFontName = res[2];
338             this._setFontToEditBox();
339         }
340     },
341 
342     /**
343      * set fontName
344      * @param {String} fontName
345      */
346     setFontName: function (fontName) {
347         this._edFontName = fontName;
348         this._setFontToEditBox();
349     },
350 
351     /**
352      * set fontSize
353      * @param {Number} fontSize
354      */
355     setFontSize: function (fontSize) {
356         this._edFontSize = fontSize;
357         this._setFontToEditBox();
358     },
359 
360     _setFontToEditBox: function () {
361         if (this._edTxt.value !== this._placeholderText) {
362             this._edTxt.style.fontFamily = this._edFontName;
363             this._edTxt.style.fontSize = this._edFontSize + "px";
364             if (this._editBoxInputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD)
365                 this._edTxt.type = "password";
366             else
367                 this._edTxt.type = "text";
368         }
369     },
370 
371     /**
372      *  Set the text entered in the edit box.
373      * @deprecated
374      * @param {string} text The given text.
375      */
376     setText: function (text) {
377         cc.log("Please use the setString");
378         this.setString(text);
379     },
380 
381     /**
382      *  Set the text entered in the edit box.
383      * @param {string} text The given text.
384      */
385     setString: function (text) {
386         if (text != null) {
387             if (text === "") {
388                 this._edTxt.value = this._placeholderText;
389                 this._edTxt.style.color = cc.colorToHex(this._placeholderColor);
390                 this._edTxt.type = "text";
391             } else {
392                 this._edTxt.value = text;
393                 this._edTxt.style.color = cc.colorToHex(this._textColor);
394                 if (this._editBoxInputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD)
395                     this._edTxt.type = "password";
396                 else
397                     this._edTxt.type = "text";
398             }
399         }
400     },
401 
402     /**
403      * Set the font color of the widget's text.
404      * @param {cc.Color} color
405      */
406     setFontColor: function (color) {
407         this._textColor = color;
408         if (this._edTxt.value !== this._placeholderText) {
409             this._edTxt.style.color = cc.colorToHex(color);
410         }
411     },
412 
413     /**
414      * <p>
415      * Sets the maximum input length of the edit box. <br/>
416      * Setting this value enables multiline input mode by default.
417      * </p>
418      * @param {Number} maxLength The maximum length.
419      */
420     setMaxLength: function (maxLength) {
421         if (!isNaN(maxLength) && maxLength > 0) {
422             this._maxLength = maxLength;
423             this._edTxt.maxLength = maxLength;
424         }
425     },
426 
427     /**
428      * Gets the maximum input length of the edit box.
429      * @return {Number} Maximum input length.
430      */
431     getMaxLength: function () {
432         return this._maxLength;
433     },
434 
435     /**
436      * Set a text in the edit box that acts as a placeholder when an edit box is empty.
437      * @param {string} text The given text.
438      */
439     setPlaceHolder: function (text) {
440         if (text != null) {
441             var oldPlaceholderText = this._placeholderText;
442             this._placeholderText = text;
443             if (this._edTxt.value === oldPlaceholderText) {
444                 this._edTxt.value = text;
445                 this._edTxt.style.color = cc.colorToHex(this._placeholderColor);
446                 this._setPlaceholderFontToEditText();
447             }
448         }
449     },
450 
451     /**
452      * Set the placeholder's font.
453      * @param {String} fontName
454      * @param {Number} fontSize
455      */
456     setPlaceholderFont: function (fontName, fontSize) {
457         this._placeholderFontName = fontName;
458         this._placeholderFontSize = fontSize;
459         this._setPlaceholderFontToEditText();
460     },
461     _setPlaceholderFont: function (fontStyle) {
462         var res = cc.LabelTTF._fontStyleRE.exec(fontStyle);
463         if (res) {
464             this._placeholderFontName = res[2];
465             this._placeholderFontSize = parseInt(res[1]);
466             this._setPlaceholderFontToEditText();
467         }
468     },
469 
470     /**
471      * Set the placeholder's fontName.
472      * @param {String} fontName
473      */
474     setPlaceholderFontName: function (fontName) {
475         this._placeholderFontName = fontName;
476         this._setPlaceholderFontToEditText();
477     },
478 
479     /**
480      * Set the placeholder's fontSize.
481      * @param {Number} fontSize
482      */
483     setPlaceholderFontSize: function (fontSize) {
484         this._placeholderFontSize = fontSize;
485         this._setPlaceholderFontToEditText();
486     },
487 
488     _setPlaceholderFontToEditText: function () {
489         if (this._edTxt.value === this._placeholderText) {
490             this._edTxt.style.fontFamily = this._placeholderFontName;
491             this._edTxt.style.fontSize = this._placeholderFontSize + "px";
492             this._edTxt.type = "text";
493         }
494     },
495 
496     /**
497      * Set the font color of the placeholder text when the edit box is empty.
498      * @param {cc.Color} color
499      */
500     setPlaceholderFontColor: function (color) {
501         this._placeholderColor = color;
502         if (this._edTxt.value === this._placeholderText) {
503             this._edTxt.style.color = cc.colorToHex(color);
504         }
505     },
506 
507     /**
508      * Set the input flags that are to be applied to the edit box.
509      * @param {Number} inputFlag One of the EditBoxInputFlag constants.
510      * e.g.cc.EDITBOX_INPUT_FLAG_PASSWORD
511      */
512     setInputFlag: function (inputFlag) {
513         this._editBoxInputFlag = inputFlag;
514         if ((this._edTxt.value !== this._placeholderText) && (inputFlag === cc.EDITBOX_INPUT_FLAG_PASSWORD))
515             this._edTxt.type = "password";
516         else
517             this._edTxt.type = "text";
518     },
519 
520     /**
521      * Gets the  input string of the edit box.
522      * @deprecated
523      * @return {string}
524      */
525     getText: function () {
526         cc.log("Please use the getString");
527         return this._edTxt.value;
528     },
529 
530     /**
531      * Gets the  input string of the edit box.
532      * @return {string}
533      */
534     getString: function () {
535         if(this._edTxt.value === this._placeholderText)
536             return "";
537         return this._edTxt.value;
538     },
539 
540     /**
541      * Init edit box with specified size.
542      * @param {cc.Size} size
543      * @param {cc.Color | cc.Scale9Sprite} normal9SpriteBg
544      */
545     initWithSizeAndBackgroundSprite: function (size, normal9SpriteBg) {
546         if (this.initWithBackgroundSprite(normal9SpriteBg)) {
547             this._domInputSprite.x = 3;
548             this._domInputSprite.y = 3;
549 
550             this.setZoomOnTouchDown(false);
551             this.setPreferredSize(size);
552             this.x = 0;
553             this.y = 0;
554             this._addTargetWithActionForControlEvent(this, this.touchDownAction, cc.CONTROL_EVENT_TOUCH_UP_INSIDE);
555             return true;
556         }
557         return false;
558     },
559 
560     /* override functions */
561     /**
562      * Set the delegate for edit box.
563      * @param {cc.EditBoxDelegate} delegate
564      */
565     setDelegate: function (delegate) {
566         this._delegate = delegate;
567     },
568 
569     /**
570      * Get a text in the edit box that acts as a placeholder when an
571      * edit box is empty.
572      * @return {String}
573      */
574     getPlaceHolder: function () {
575         return this._placeholderText;
576     },
577 
578     /**
579      * Set the input mode of the edit box.
580      * @param {Number} inputMode One of the EditBoxInputMode constants.
581      */
582     setInputMode: function (inputMode) {
583         this._editBoxInputMode = inputMode;
584     },
585 
586     /**
587      * Set the return type that are to be applied to the edit box.
588      * @param {Number} returnType One of the CCKeyboardReturnType constants.
589      */
590     setReturnType: function (returnType) {
591         this._keyboardReturnType = returnType;
592     },
593 
594     keyboardWillShow: function (info) {
595         var rectTracked = cc.EditBox.getRect(this);
596         // some adjustment for margin between the keyboard and the edit box.
597         rectTracked.y -= 4;
598         // if the keyboard area doesn't intersect with the tracking node area, nothing needs to be done.
599         if (!rectTracked.intersectsRect(info.end)) {
600             cc.log("needn't to adjust view layout.");
601             return;
602         }
603 
604         // assume keyboard at the bottom of screen, calculate the vertical adjustment.
605         this._adjustHeight = info.end.getMaxY() - rectTracked.getMinY();
606         // CCLOG("CCEditBox:needAdjustVerticalPosition(%f)", m_fAdjustHeight);
607 
608         //callback
609     },
610     keyboardDidShow: function (info) {
611     },
612     keyboardWillHide: function (info) {
613         //if (m_pEditBoxImpl != NULL) {
614         //    m_pEditBoxImpl->doAnimationWhenKeyboardMove(info.duration, -m_fAdjustHeight);
615         //}
616     },
617     keyboardDidHide: function (info) {
618     },
619 
620     touchDownAction: function (sender, controlEvent) {
621         //this._editBoxImpl.openKeyboard();
622     },
623 
624     /**
625      * @warning HTML5 Only
626      * @param {cc.Size} size
627      * @param {cc.color} bgColor
628      */
629     initWithBackgroundColor: function (size, bgColor) {
630         this._edWidth = size.width;
631         this.dom.style.width = this._edWidth.toString() + "px";
632         this._edHeight = size.height;
633         this.dom.style.height = this._edHeight.toString() + "px";
634         this.dom.style.backgroundColor = cc.colorToHex(bgColor);
635     }
636 });
637 
638 var _p = cc.EditBox.prototype;
639 
640 // Extended properties
641 /** @expose */
642 _p.font;
643 cc.defineGetterSetter(_p, "font", null, _p._setFont);
644 /** @expose */
645 _p.fontName;
646 cc.defineGetterSetter(_p, "fontName", null, _p.setFontName);
647 /** @expose */
648 _p.fontSize;
649 cc.defineGetterSetter(_p, "fontSize", null, _p.setFontSize);
650 /** @expose */
651 _p.fontColor;
652 cc.defineGetterSetter(_p, "fontColor", null, _p.setFontColor);
653 /** @expose */
654 _p.string;
655 cc.defineGetterSetter(_p, "string", _p.getString, _p.setString);
656 /** @expose */
657 _p.maxLength;
658 cc.defineGetterSetter(_p, "maxLength", _p.getMaxLength, _p.setMaxLength);
659 /** @expose */
660 _p.placeHolder;
661 cc.defineGetterSetter(_p, "placeHolder", _p.getPlaceHolder, _p.setPlaceHolder);
662 /** @expose */
663 _p.placeHolderFont;
664 cc.defineGetterSetter(_p, "placeHolderFont", null, _p._setPlaceholderFont);
665 /** @expose */
666 _p.placeHolderFontName;
667 cc.defineGetterSetter(_p, "placeHolderFontName", null, _p.setPlaceholderFontName);
668 /** @expose */
669 _p.placeHolderFontSize;
670 cc.defineGetterSetter(_p, "placeHolderFontSize", null, _p.setPlaceholderFontSize);
671 /** @expose */
672 _p.placeHolderFontColor;
673 cc.defineGetterSetter(_p, "placeHolderFontColor", null, _p.setPlaceholderFontColor);
674 /** @expose */
675 _p.inputFlag;
676 cc.defineGetterSetter(_p, "inputFlag", null, _p.setInputFlag);
677 /** @expose */
678 _p.delegate;
679 cc.defineGetterSetter(_p, "delegate", null, _p.setDelegate);
680 /** @expose */
681 _p.inputMode;
682 cc.defineGetterSetter(_p, "inputMode", null, _p.setInputMode);
683 /** @expose */
684 _p.returnType;
685 cc.defineGetterSetter(_p, "returnType", null, _p.setReturnType);
686 
687 _p = null;
688 
689 /**
690  * get the rect of a node in world coordinate frame
691  * @function
692  * @param {cc.Node} node
693  * @return {cc.Rect}
694  */
695 cc.EditBox.getRect = function (node) {
696     var contentSize = node.getContentSize();
697     var rect = cc.rect(0, 0, contentSize.width, contentSize.height);
698     return cc.rectApplyAffineTransform(rect, node.getNodeToWorldTransform());
699 };
700 
701 /**
702  * create a edit box with size and background-color or
703  * @deprecated since v3.0, please use new cc.EditBox(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) instead
704  * @param {cc.Size} size
705  * @param {cc.Scale9Sprite } normal9SpriteBg
706  * @param {cc.Scale9Sprite } [press9SpriteBg]
707  * @param {cc.Scale9Sprite } [disabled9SpriteBg]
708  * @return {cc.EditBox}
709  */
710 cc.EditBox.create = function (size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg) {
711     return new cc.EditBox(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg);
712 };
713 
714 
715 
716 
717