Class: InputControl

InputControl

InputControl

new GOWN.InputControl(theme)

InputControl used for TextInput, TextArea and everything else that is capable of entering text roughly based on PIXI.Input InputObject by Sebastian Nette, see https://github.com/SebastianNette/PIXI.Input
Name Type Description
theme GOWN.Theme optional theme for the input control

Extends

Members

staticGOWN.InputControl.currentInputGOWN.InputControl

Currently selected input control (used for tab index)

static,readonlyGOWN.InputControl.DOWNString

Down state: mouse button is pressed or finger touches the screen

static,readonlyGOWN.InputControl.HOVERString

Hover state: mouse pointer hovers over the button (ignored on mobile)

static,readonlyGOWN.InputControl.OUTString

Hover state: mouse pointer hovers over the button (ignored on mobile)

static,readonlyGOWN.InputControl.UPString

Up state: mouse button is released or finger is removed from the screen

allowDestroyCachebool

Will destroy the skin cache when the skinable gets destroyed
Default Value:
  • true

autoPreventInteractionbool

Prevent other interaction (touch/move) on this component
Default Value:
  • false

blinkIntervalNumber

Interval for the cursor (in milliseconds)
Default Value:
  • 500

currentStateString

The current state TODO: move to skinable?
Default Value:
  • InputControl.UP

enabledBoolean

Enables/Disables the control. (not implemented yet)

hasFocusbool

Determine if the input has the focus
Default Value:
  • false

maxCharsString

The maximum number of characters that may be entered. If 0, any number of characters may be entered. (same as maxLength for DOM inputs)
Default Value:
  • 0

receiveKeysbool

TODO
Default Value:
  • true

selectionBgPIXI.Graphics

Text selection background

skinFallbackString

The fallback skin if the other skin does not exist (e.g. if a mobile theme that does not provide a "hover" state is used on a desktop system) (normally the default "up"-state skin)
Default Value:
  • 'up'

skinNameString

Change the skin name. You normally set the skin name as constant in your control, but if you want you can set another skin name to change skins for single components at runtime.

stylePIXI.TextStyle

Set the text style (size, font etc.) for text and cursor

textString

Set the text that is shown inside the input field. Calls onTextChange callback if text changes.
Default Value:
  • ''

Methods

Blur the text input (remove focus)

inherited changeSkin(skin)

Remove old skin and add new one
Name Type Description
skin DisplayObject

deleteSelection()

Delete the selected text

deleteText(fromPos, toPos){String}

Delete text from a start position to an end position
Name Type Description
fromPos Number start position
toPos Number end position
Returns:
Type Description
String
Destroy the Skinable and empty the skin cache
Focus on this input and set it as current

inherited fromSkin(name, callback)

Get image from skin (will execute a callback with the loaded skin when it is loaded or call it directly when it already is loaded)
Name Type Description
name String name of the state
callback function callback that is executed if the skin is loaded
Insert a char at the current cursor position
Name Type Description
char String The char that gets inserted

lineHeight(){Number}

Height of the line in pixel (assume that every character of pixi text has the same line height)
Returns:
Type Description
Number

inherited mousePos(){PIXI.Point}

Get the local mouse position from PIXI.InteractionData
Returns:
Type Description
PIXI.Point
Move the cursor left

moveCursorRight()

Move the cursor right

protectedonblur()

Callback that will be executed once the text input is blurred

protectedonDown()

onDown callback

protectedonfocus()

Callback to execute code on focus

protectedonInputChanged()

Input changed callback

protectedonMouseUpOutside()

Blurs the input when the mouse is released outside

protectedonMove()

onMove callback
onUp callback

pixelToTextPos(pixelPos){Number}

From pixel position on the text to character position inside the text (used when clicked on the text)
Name Type Description
pixelPos Pixel position of the mouse on the text
Returns:
Type Description
Number Position in the text
Initiate all skins first

protectedredraw()

Update before draw call (draw cursor and selection)
Set the cursor position on the text
Set the input control text.
Name Type Description
text String The text to set
Change the theme
Name Type Description
theme GOWN.Theme the new theme

textToPixelPos(textPos, position){PIXI.Point}

From position in the text to pixel position (for cursor/selection positioning)
Name Type Description
textPos Number Current character position in the text
position PIXI.Point optional point that will be set with the pixel position and returned
Returns:
Type Description
PIXI.Point Pixel position

textWidth(text){Number}

Get the width of a text
Name Type Description
text String The text to get the width from
Returns:
Type Description
Number

updateSelection(start, end){boolean}

Set the selected text
Name Type Description
start Number Start position in the text
end Number End position in the text
Returns:
Type Description
boolean

inherited updateTheme(data)

Overwrite data from theme for this specific component. (usable if you want to change e.g. background color based on selected items)
Name Type Description
data updated skin data