Repository
public class |source

TextField

Constructor Summary

Public Constructor
public

TextField to simulate the input textfield we can find in the DOM.

Member Summary

Public Members
public
public
public

color: *

public
public
public

font: *

public
public
public
public

height: *

public
public
public

size: *

public

width: *

Private Members
private
private
private
private
private
private
private
private
private
private

_font: *

private
private
private
private

Method Summary

Public Methods
public

addLetter(value: String)

add a letter to the field content.

public

Clears this textField : erase everything and make the cursor back to the first character place.

public

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

Moves the cursor to the given index of the letter

public

Pick the letter situated under the given x,y coordinates

public

Renders the canvas

public

setColor(color: Color)

Set the color of the next letter

public

setFont(font: Font)

Set the font.

public

setSize(size: Number)

Set the size of the next letter

Private Methods
private

Cursor blink callback

private

Setup bloc called after default font loading

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:

NameTypeAttributeDescription
paramsObject

Parameters object, given by the constructor.

params.maxCharCountNumber
  • optional
  • default: 1000
params.sizeNumber
  • optional
  • default: 20
params.colorCSSColor
  • optional
  • default: "gray"
params.backgroundColorCSSColor
  • optional
  • default: "white"
params.marginsNumber
  • optional
  • default: 10
params.widthNumber
  • optional
  • default: 300
params.heightNumber
  • optional
  • default: 100
params.fontFont
  • optional
  • default: undefined
params.fontItalicFont
  • optional
  • default: undefined
params.fontBoldFont
  • optional
  • default: undefined
params.fontBoldItalicFont
  • optional
  • default: undefined
params.cursorColorCSSColor
  • optional
  • default: "gray"
params.cursorWidthNumber
  • optional
  • default: 2
params.blinkTimeNumber
  • optional
  • default: 300

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 _blinkState: boolean source

private _boldFont: * source

private _boldItalicFont: * source

private _canvas: * source

private _canvasContext: * source

private _currentFont: * source

private _cursorIndex: * source

private _cursorX: number source

private _cursorY: number source

private _font: * source

private _italicFont: * source

private _ready: boolean source

private _styledLetters: *[] source

private _text: string 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:

NameTypeAttributeDescription
valueString

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 getCanvas(): Canvas source

Get the canvas

Return:

Canvas

canvas

public getHeight(): Number source

Get canvas height

Return:

Number

canvas height

public getText(): String source

Get the text displayed as a string

Return:

String

the text displayed in this TextField

public getWidth(): Number source

Get canvas width

Return:

Number

canvas width

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:

NameTypeAttributeDescription
indexNumber

public pickLetter(x: Number, y: Number): * source

Pick the letter situated under the given x,y coordinates

Params:

NameTypeAttributeDescription
xNumber
yNumber

Return:

*

public render() source

Renders the canvas

public setColor(color: Color) source

Set the color of the next letter

Params:

NameTypeAttributeDescription
colorColor

the new Mobilizing Color

public setFont(font: Font) source

Set the font.

Params:

NameTypeAttributeDescription
fontFont

Mobilizing font to use for the next letter

public setSize(size: Number) source

Set the size of the next letter

Params:

NameTypeAttributeDescription
sizeNumber

the new size of the font

Private Methods

Cursor blink callback

private setup() source

Setup bloc called after default font loading