import TextField from '@mobilizing/library/js/Mobilizing/text/TextField.js'
TextField
Constructor Summary
Public Constructor | ||
public | constructor(params: Object) TextField to simulate the input textfield we can find in the DOM. |
Member Summary
Public Members | ||
public | ||
public | blinkTime: * | |
public | color: * | |
public | cursorColor: * | |
public | cursorWidth: * | |
public | font: * | |
public | fontBold: * | |
public | ||
public | fontItalic: * | |
public | height: * | |
public | margins: * | |
public | maxCharCount: * | |
public | size: * | |
public | width: * |
Private Members | ||
private | ||
private | _boldFont: * | |
private | ||
private | _canvas: * | |
private | ||
private | _currentFont: * | |
private | _cursorIndex: * | |
private | ||
private | ||
private | _font: * | |
private | _italicFont: * | |
private | ||
private | _styledLetters: *[] | |
private |
Method Summary
Public Methods | ||
public | add a letter to the field content. | |
public | clear() Clears this textField : erase everything and make the cursor back to the first character place. | |
public | delete() Delete the letter currently before the cursor (or under selection when implemented) | |
public | getCanvas(): Canvas Get the canvas | |
public | Get canvas height | |
public | Get the text displayed as a string | |
public | Get canvas width | |
public | Moves the cursor to the pevious letter | |
public | Moves the cursor to the next letter | |
public | moveCursorTo(index: Number) Moves the cursor to the given index of the letter | |
public | pickLetter(x: Number, y: Number): * Pick the letter situated under the given x,y coordinates | |
public | render() Renders the canvas | |
public | Set the color of the next letter | |
public | Set the font. | |
public | Set the size of the next letter |
Public Constructors
public constructor(params: Object) source
TextField to simulate the input textfield we can find in the DOM. This is implemented in an HTLM Canvas so it can be rendered in a texture.
Params:
Name | Type | Attribute | Description |
params | Object | Parameters object, given by the constructor. | |
params.maxCharCount | Number |
| |
params.size | Number |
| |
params.color | CSSColor |
| |
params.backgroundColor | CSSColor |
| |
params.margins | Number |
| |
params.width | Number |
| |
params.height | Number |
| |
params.font | Font |
| |
params.fontItalic | Font |
| |
params.fontBold | Font |
| |
params.fontBoldItalic | Font |
| |
params.cursorColor | CSSColor |
| |
params.cursorWidth | Number |
| |
params.blinkTime | Number |
|
Example:
//TODO
Public Members
public backgroundColor: * source
public blinkTime: * source
public color: * source
public cursorColor: * source
public cursorWidth: * source
public font: * source
public fontBold: * source
public fontBoldItalic: * source
public fontItalic: * source
public height: * source
public margins: * source
public maxCharCount: * source
public size: * source
public width: * source
Private Members
private _boldFont: * source
private _boldItalicFont: * source
private _canvas: * source
private _canvasContext: * source
private _currentFont: * source
private _cursorIndex: * source
private _font: * source
private _italicFont: * source
private _styledLetters: *[] source
Public Methods
public addLetter(value: String) source
add a letter to the field content. Styles (font, color, etc) should be defined before calling this method.
Params:
Name | Type | Attribute | Description |
value | String | the letter to add |
public clear() source
Clears this textField : erase everything and make the cursor back to the first character place.
public delete() source
Delete the letter currently before the cursor (or under selection when implemented)
public getText(): String source
Get the text displayed as a string
Return:
String | the text displayed in this TextField |
public moveCursorBack() source
Moves the cursor to the pevious letter
public moveCursorForward() source
Moves the cursor to the next letter
public moveCursorTo(index: Number) source
Moves the cursor to the given index of the letter
Params:
Name | Type | Attribute | Description |
index | Number |
public pickLetter(x: Number, y: Number): * source
Pick the letter situated under the given x,y coordinates
Return:
* |
public render() source
Renders the canvas
public setColor(color: Color) source
Set the color of the next letter
Params:
Name | Type | Attribute | Description |
color | Color | the new Mobilizing Color |
public setFont(font: Font) source
Set the font.
Params:
Name | Type | Attribute | Description |
font | Font | Mobilizing font to use for the next letter |
public setSize(size: Number) source
Set the size of the next letter
Params:
Name | Type | Attribute | Description |
size | Number | the new size of the font |
Private Methods
private onBlink() source
Cursor blink callback
private setup() source
Setup bloc called after default font loading