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