FlxInputText
| Kind | class |
| Package | flixel.addons.ui |
| Full name | flixel.addons.ui.FlxInputText |
| Source | source/source-haxelib-patches/flixel/addons/ui/FlxInputText.hx |
| Extends | FlxText |
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
| Name | Type | Static | Default | Notes |
|---|---|---|---|---|
NO_FILTER | Int | yes | 0 | — |
ONLY_ALPHA | Int | yes | 1 | — |
ONLY_NUMERIC | Int | yes | 2 | — |
ONLY_ALPHANUMERIC | Int | yes | 3 | — |
CUSTOM_FILTER | Int | yes | 4 | — |
ALL_CASES | Int | yes | 0 | — |
UPPER_CASE | Int | yes | 1 | — |
LOWER_CASE | Int | yes | 2 | — |
BACKSPACE_ACTION | String | yes | "backspace" | — |
DELETE_ACTION | String | yes | "delete" | — |
ENTER_ACTION | String | yes | "enter" | — |
INPUT_ACTION | String | yes | "input" | — |
PASTE_ACTION | String | yes | "paste" | — |
COPY_ACTION | String | yes | "copy" | — |
CUT_ACTION | String | yes | "cut" | — |
customFilterPattern | EReg | no | — | property (default, set) · This regular expression will filter out (remove) everything that matches. Automatically sets filterMode = FlxInputText.CUSTOM_FILTER. |
callback | String->String->Void | no | — | A function called whenever the value changes from user input, or enter is pressed |
background | Bool | no | false | Whether or not the textbox has a background |
caretColor | Int | no | — | property (default, set) · The caret's color. Has the same color as the text by default. |
caretWidth | Int | no | 1 | property (default, set) |
params | Array<Dynamic> | no | — | property (default, set) |
passwordMode | Bool | no | — | property (get, set) · Whether or not the textfield is a password textfield |
hasFocus | Bool | no | false | property (default, set) · Whether or not the text box is the active object on the screen. |
caretIndex | Int | no | 0 | property (default, set) · The position of the selection cursor. An index of 0 means the carat is before the character at index 0. |
focusGained | Void->Void | no | — | callback that is triggered when this text field gets focus @since 2.2.0 |
focusLost | Void->Void | no | — | callback that is triggered when this text field loses focus @since 2.2.0 |
forceCase | Int | no | ALL_CASES | property (default, set) · The Case that's being enforced. Either ALL_CASES, UPPER_CASE or LOWER_CASE. |
maxLength | Int | no | 0 | property (default, set) · Set the maximum length for the field (e.g. "3" for Arcade type hi-score initials). 0 means unlimited. |
lines | Int | no | — | property (default, set) · Change the amount of lines that are allowed. |
filterMode | Int | no | NO_FILTER | property (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) |
fieldBorderColor | Int | no | FlxColor.BLACK | property (default, set) · The color of the fieldBorders |
fieldBorderThickness | Int | no | 1 | property (default, set) · The thickness of the fieldBorders |
backgroundColor | Int | no | FlxColor.WHITE | property (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
| Parameter | Type | Default |
|---|---|---|
X (optional) | Float | 0 |
Y (optional) | Float | 0 |
Width (optional) | Int | 150 |
Text (optional) | String | — |
size (optional) | Int | 8 |
TextColor (optional) | Int | FlxColor.BLACK |
BackgroundColor (optional) | Int | FlxColor.WHITE |
EmbeddedFont (optional) | Bool | true |
destroy
override function destroy():Void
Clean up memory
draw
override function draw():Void
Draw the caret in addition to the text.
update
override function update(elapsed:Float):Void
Check for mouse input every tick.
| Parameter | Type | Default |
|---|---|---|
elapsed | Float | — |
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
backgroundSprite | FlxSprite | no |
_caretTimer | FlxTimer | no |
caret | FlxSprite | no |
fieldBorderSprite | FlxSprite | no |
_scrollBoundIndeces | {left:Int, right:Int} | no |
_charBoundaries | Array<FlxRect> | no |
lastScroll | Int | no |
| 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 |