Class cc.TextFieldTTF
- Defined in: CCTextFieldTTF.js
- Extends cc.LabelTTF
Constructor Attributes | Constructor Name and Description |
---|---|
cc.TextFieldTTF(placeholder, dimensions, alignment, fontName, fontSize)
A simple text input field with TTF font.
|
Method Summary
Class Detail
cc.TextFieldTTF(placeholder, dimensions, alignment, fontName, fontSize)
A simple text input field with TTF font.
//example // When five parameters var textField = new cc.TextFieldTTF("", cc.size(100,50), cc.TEXT_ALIGNMENT_LEFT,"Arial", 32); // When three parameters var textField = new cc.TextFieldTTF(" ", "Arial", 32);
- Parameters:
- {String} placeholder
- {cc.Size} dimensions
- {Number} alignment
- {String} fontName
- {Number} fontSize
Method Detail
-
{Boolean} attachWithIME()Open keyboard and receive input text.
- Returns:
- {Boolean}
-
{Boolean} canAttachWithIME()Return whether to allow attach with IME.
- Returns:
- {Boolean}
-
{Boolean} canDetachWithIME()Return whether to allow detach with IME.
- Returns:
- {Boolean}
-
<static> {cc.TextFieldTTF|Null} cc.TextFieldTTF.create(placeholder, dimensions, alignment, fontName, fontSize)Please use new TextFieldTTF instead.
Creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size.- Parameters:
- {String} placeholder
- {cc.Size} dimensions
- {Number} alignment
- {String} fontName
- {Number} fontSize
- Deprecated:
- since v3.0 Please use new TextFieldTTF instead.
- Returns:
- {cc.TextFieldTTF|Null}
-
ctor(placeholder, dimensions, alignment, fontName, fontSize)Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
creates a cc.TextFieldTTF from a fontName, alignment, dimension and font size.- Parameters:
- {String} placeholder
- {cc.Size} dimensions
- {Number} alignment
- {String} fontName
- {Number} fontSize
-
deleteBackward()Delete backward
-
{Boolean} detachWithIME()End text input and close keyboard.
- Returns:
- {Boolean}
-
didAttachWithIME()When the delegate detach with IME, this method call by CCIMEDispatcher.
-
didDetachWithIME()When the delegate detach with IME, this method call by CCIMEDispatcher.
-
draw(ctx)Render function using the canvas 2d context or WebGL context, internal usage only, please do not call this function.
- Parameters:
- {CanvasRenderingContext2D | WebGLRenderingContext} ctx
- The render context
-
{Number} getCharCount()Gets the char count.
- Returns:
- {Number}
-
{cc.Color} getColorSpaceHolder()Returns the color of space holder.
- Returns:
- {cc.Color}
-
{String} getContentText()Gets the input text.
- Returns:
- {String}
-
{cc.Node} getDelegate()Gets the delegate.
- Returns:
- {cc.Node}
-
{String} getPlaceHolder()Gets the place holder.
default display string.- Returns:
- {String}
-
{String} getString()Gets the string
- Returns:
- {String}
-
{string} getTipMessage()Gets the input tip message to show on mobile browser. (mobile Web only)
- Returns:
- {string}
-
{Boolean} initWithPlaceHolder(placeholder, dimensions, alignment, fontName, fontSize)Initializes the cc.TextFieldTTF with a font name, alignment, dimension and font size
//example var textField = new cc.TextFieldTTF(); // When five parameters textField.initWithPlaceHolder("
", cc.size(100,50), cc.TEXT_ALIGNMENT_LEFT,"Arial", 32); // When three parameters textField.initWithPlaceHolder(" ", "Arial", 32); - Parameters:
- {String} placeholder
- {cc.Size} dimensions
- {Number} alignment
- {String} fontName
- {Number} fontSize
- Returns:
- {Boolean}
-
insertText(text, len)Append the text.
Input the character.- Parameters:
- {String} text
- {Number} len
-
removeDelegate()Remove delegate
-
setColorSpaceHolder(value)Sets the color of space holder.
- Parameters:
- {cc.Color} value
-
setDelegate(value)Set the delegate.
- Parameters:
- {cc.Node} value
-
setPlaceHolder(text)Set the place holder.
display this string if string equal "".- Parameters:
- {String} text
-
setString(text)Input text property
- Parameters:
- {String} text
-
setTextColor(textColor)Sets the color of cc.TextFieldTTF's text.
- Parameters:
- {cc.Color} textColor
-
setTipMessage(tipMessage)Sets the input tip message to show on mobile browser. (mobile Web only)
- Parameters:
- {string} tipMessage
-
visit(ctx)Recursive method that visit its children and draw them.
- Parameters:
- {CanvasRenderingContext2D|WebGLRenderingContext} ctx