Skip to main content

FlxInputText

Kindclass
Packageflixel.addons.ui
Full nameflixel.addons.ui.FlxInputText
Sourcesource/source-haxelib-patches/flixel/addons/ui/FlxInputText.hx
ExtendsFlxText

FlxInputText v1.11, ported to Haxe @author larsiusprime, (Lars Doucet) @link http://github.com/haxeflixel/flixel-ui

FlxInputText v1.10, Input text field extension for Flixel @author Gama11, Mr_Walrus, nitram_cero (Martín Sebastián Wain) @link http://forums.flixel.org/index.php/topic,272.0.html

Copyright (c) 2009 Martín Sebastián Wain License: Creative Commons Attribution 3.0 United States @link http://creativecommons.org/licenses/by/3.0/us/

Known subclasses: FlxUIInputText

Public fields​

NameTypeStaticDefaultNotes
NO_FILTERIntyes0—
ONLY_ALPHAIntyes1—
ONLY_NUMERICIntyes2—
ONLY_ALPHANUMERICIntyes3—
CUSTOM_FILTERIntyes4—
ALL_CASESIntyes0—
UPPER_CASEIntyes1—
LOWER_CASEIntyes2—
BACKSPACE_ACTIONStringyes"backspace"—
DELETE_ACTIONStringyes"delete"—
ENTER_ACTIONStringyes"enter"—
INPUT_ACTIONStringyes"input"—
PASTE_ACTIONStringyes"paste"—
COPY_ACTIONStringyes"copy"—
CUT_ACTIONStringyes"cut"—
customFilterPatternERegno—property (default, set) · This regular expression will filter out (remove) everything that matches. Automatically sets filterMode = FlxInputText.CUSTOM_FILTER.
callbackString->String->Voidno—A function called whenever the value changes from user input, or enter is pressed
backgroundBoolnofalseWhether or not the textbox has a background
caretColorIntno—property (default, set) · The caret's color. Has the same color as the text by default.
caretWidthIntno1property (default, set)
paramsArray<Dynamic>no—property (default, set)
passwordModeBoolno—property (get, set) · Whether or not the textfield is a password textfield
hasFocusBoolnofalseproperty (default, set) · Whether or not the text box is the active object on the screen.
caretIndexIntno0property (default, set) · The position of the selection cursor. An index of 0 means the carat is before the character at index 0.
focusGainedVoid->Voidno—callback that is triggered when this text field gets focus @since 2.2.0
focusLostVoid->Voidno—callback that is triggered when this text field loses focus @since 2.2.0
forceCaseIntnoALL_CASESproperty (default, set) · The Case that's being enforced. Either ALL_CASES, UPPER_CASE or LOWER_CASE.
maxLengthIntno0property (default, set) · Set the maximum length for the field (e.g. "3" for Arcade type hi-score initials). 0 means unlimited.
linesIntno—property (default, set) · Change the amount of lines that are allowed.
filterModeIntnoNO_FILTERproperty (default, set) · Defines what text to filter. It can be NO_FILTER, ONLY_ALPHA, ONLY_NUMERIC, ONLY_ALPHA_NUMERIC or CUSTOM_FILTER (Remember to append "FlxInputText." as a prefix to those constants)
fieldBorderColorIntnoFlxColor.BLACKproperty (default, set) · The color of the fieldBorders
fieldBorderThicknessIntno1property (default, set) · The thickness of the fieldBorders
backgroundColorIntnoFlxColor.WHITEproperty (default, set) · The color of the background of the textbox.

Public methods​

new (constructor)​

function new(X:Float = 0, Y:Float = 0, Width:Int = 150, ?Text:String, size:Int = 8, TextColor:Int = FlxColor.BLACK, BackgroundColor:Int = FlxColor.WHITE, EmbeddedFont:Bool = true)

@param X The X position of the text. @param Y The Y position of the text. @param Width The width of the text object (height is determined automatically). @param Text The actual text you would like to display initially. @param size Initial size of the font @param TextColor The color of the text @param BackgroundColor The color of the background (FlxColor.TRANSPARENT for no background color) @param EmbeddedFont Whether this text field uses embedded fonts or not

ParameterTypeDefault
X (optional)Float0
Y (optional)Float0
Width (optional)Int150
Text (optional)String—
size (optional)Int8
TextColor (optional)IntFlxColor.BLACK
BackgroundColor (optional)IntFlxColor.WHITE
EmbeddedFont (optional)Booltrue

View source

destroy​

override function destroy():Void

Clean up memory

View source

draw​

override function draw():Void

Draw the caret in addition to the text.

View source

update​

override function update(elapsed:Float):Void

Check for mouse input every tick.

ParameterTypeDefault
elapsedFloat—

View source

Internals​

Private / internal members
FieldTypeStatic
backgroundSpriteFlxSpriteno
_caretTimerFlxTimerno
caretFlxSpriteno
fieldBorderSpriteFlxSpriteno
_scrollBoundIndeces{left:Int, right:Int}no
_charBoundariesArray<FlxRect>no
lastScrollIntno
Method
function set_customFilterPattern(cfp:EReg)
function set_caretColor(i:Int):Int
function set_caretWidth(i:Int):Int
function drawSprite(Sprite:FlxSprite):Void
function onKeyDown(e:KeyboardEvent):Void
function onChange(action:String):Void
function insertSubstring(Original:String, Insert:String, Index:Int):String
function getCaretIndex():Int
function getCharBoundaries(charIndex:Int):Rectangle
override function set_text(Text:String):String
function getCharIndexAtPoint(X:Float, Y:Float):Int
function prepareCharBoundaries(numChars:Int):Void
function onSetTextCheck():Void
override function calcFrame(RunOnCpp:Bool = false):Void
function toggleCaret(timer:FlxTimer):Void
function filter(text:String):String
function set_params(p:Array<Dynamic>):Array<Dynamic>
override function set_x(X:Float):Float
override function set_y(Y:Float):Float
function set_hasFocus(newFocus:Bool):Bool
function getAlignStr():FlxTextAlign
function set_caretIndex(newCaretIndex:Int):Int
function set_forceCase(Value:Int):Int
override function set_size(Value:Int):Int
function set_maxLength(Value:Int):Int
function set_lines(Value:Int):Int
function get_passwordMode():Bool
function set_passwordMode(value:Bool):Bool
function set_filterMode(Value:Int):Int
function set_fieldBorderColor(Value:Int):Int
function set_fieldBorderThickness(Value:Int):Int
function set_backgroundColor(Value:Int):Int