EditBox

The EditBox is the generic text-input window element.

Summary
EditBoxThe EditBox is the generic text-input window element.
Implementation DetailsWhile in focus, the edit box will show a blinking cursor and trap (and display) all keyboard input.
XML DefinitionThis is the EditBox xml definition.
XML Tag
Required AttributesYou need to specify valid values for all of these elements to get the ComboBox to create properly.
fontThe name of the Font definition to use.
Optional AttributesThese are optional.
maxcharsThe maximum number of characters allowed to be displayed.
scrollbarThe name of a <VerticalScrollBar> to use if the text exceeds the height of the window when in .
backgroundThe name of a FullResizeImage to use as a background.
linespacingAn override value for the font line spacing.
passwordThe edit box should work like a password box and display asterisk instead of the actual characters typed.
scrollingThe scrolling mode to use.
inputThe type of input this EditBox should accept.
historyThe size of the input history (tracked automatically when the enter key is pressed) to track.
Elements
MenuButtonOffsetThe offset of the menu buttons within their background.
Elements
TextColorThe color for the text.
TextOffsetThe offset for the text within the EditBox dimensions.
Window CallbacksThese are the EditBox specific callback events.
Callbacks
OnTextChangedCalled when the the text inside the edit box changes.
Functions
Functions
EditBoxSetText()Sets the text currently displayed.
EditBoxGetText()Returns the text currently displayed.
EditBoxGetTextLines()Returns the text currently displayed.
Functions
Functions
EditBoxInsertText()Inserts text at the current cursor location.
EditBoxSetTextColor()Sets the color for the text display.
EditBoxGetTextColor()Returns the current text color for the display.
TextEditBoxSelectAll()Selects all of the text.
EditBoxSetFont()Sets the font for the text display
EditBoxGetFont()Returns the name of the font currently used.
EditBoxGetHistory()Returns the input history for the EditBox.
EditBoxSetHistory()Sets the input history for the edit box.
EditBoxSetHandleKeyDown()Allows you to disable text from automatically being added to the EditBox display when a key is pressed.

Implementation Details

While in focus, the edit box will show a blinking cursor and trap (and display) all keyboard input.

You can set focus to an edit box by manually calling <WindowSetFocus()>, or by clicking on it with the mouse.

Scrolling Modes

The edit box can be created in two separate scrolling modes.

horizontalThe text will always remain on one line and scroll left->right based on your cursor position.
verticalThe text will line wrap and and scroll once it reaches the end of the box.  ( NOTE: Scrolling is currently broken - text will not extend beyond the bottom of the box)

Input Restrictions

You can restrict an edit box only to accept a certain type of input.

”all”Accept all characters.
”nospaces”Accepts all character except for spaces.
”text”Accepts only text.
”numbers”Accepts only numbers.

Keyboard Commands

Basic Arrow KeysMoves you cursor left, right, up, and down in the text.
Shift Up/Down ArrowMoves backward/forward through the input history.
Shift Left/Right ArrowSelects character to the left/right of the cursor.
Shift-Control Left/Right ArrowSelects the entire word to the left/right of the cursor.
Control Left/Right ArrowMoves the cursor one word to the left/right.
Home KeyMoves the cursor to the beginning of the text.
Shift Home KeySelects all the text between the cursor location and the beginning of the text.
End KeyMoves the cursor to the end of the text.
Shift End KeySelects all the text between the cursor location and the end of the text.
Delete KeyDeletes the selected text, or the text immediately after the cursor.
Backspace KeyDeletes the selected text, or the text immediately before the cursor.
Control Backspace KeyDeletes the entire word before the cursor.
Enter KeyAdds the current text to the input history (if a history size is specified).  You are responsible for handling the <OnKeyEnter()> event to clear the text if that is the desired behavior
Control-ASelects all of the text.
Control-CCopies the selected text to the Window’s Clipboard.
Control-VPastes text currently on the Window’s Clipboard into the EditBox.
Control-XCuts the selected text to the Window’s Clipboard.

XML Definition

This is the EditBox xml definition.

Summary
XML Tag
Required AttributesYou need to specify valid values for all of these elements to get the ComboBox to create properly.
fontThe name of the Font definition to use.
Optional AttributesThese are optional.
maxcharsThe maximum number of characters allowed to be displayed.
scrollbarThe name of a <VerticalScrollBar> to use if the text exceeds the height of the window when in .
backgroundThe name of a FullResizeImage to use as a background.
linespacingAn override value for the font line spacing.
passwordThe edit box should work like a password box and display asterisk instead of the actual characters typed.
scrollingThe scrolling mode to use.
inputThe type of input this EditBox should accept.
historyThe size of the input history (tracked automatically when the enter key is pressed) to track.
Elements
MenuButtonOffsetThe offset of the menu buttons within their background.
Elements
TextColorThe color for the text.
TextOffsetThe offset for the text within the EditBox dimensions.

XML Tag

<EditBox>
....
</EditBox>

Required Attributes

You need to specify valid values for all of these elements to get the ComboBox to create properly.

font

The name of the Font definition to use.

Expects

  • A string value of a valid Font.

Optional Attributes

These are optional.  You can use whichever apply to the EditBox you are creating.

maxchars

The maximum number of characters allowed to be displayed.

Expects

  • A number greater than 0.

Default Value

  • 255

scrollbar

The name of a <VerticalScrollBar> to use if the text exceeds the height of the window when in .

Expects

A string value, which is the name of a valid Button.

Default Value

  • ””

Notes

  • Scrollbars are currently broken for edit boxes

background

The name of a FullResizeImage to use as a background.

Expects

A string value, which is the name of a valid FullResizeImage.

Default Value

  • ””

Notes

  • none

linespacing

An override value for the font line spacing.

Expects

  • A number.  If 0, the font height is used.

Default Value

  • 0

password

The edit box should work like a password box and display asterisk instead of the actual characters typed.

Expects

A boolean value.

”true”Display asterisk.
”false”Display the actual text.

Default Value

  • ”false”

scrolling

The scrolling mode to use.

Expects

A string value, that is one of the following:

”vert”Word-wrap the text.
”horiz”Scroll the text horizontally on one line.

Default Value

  • ”horiz”

input

The type of input this EditBox should accept.

Expects

A string value, that is one of the following:

”all”Accept all characters.
”nospaces”Accepts all character expect for spaces.
”text”Accepts only text.
”numbers”Accepts only numbers.

Default Value

  • ”all”

history

The size of the input history (tracked automatically when the enter key is pressed) to track.

Expects

A number value, 0 through n. Indicating the history length.

Default Value

  • 0, no history

Elements

MenuButtonOffset

The offset of the menu buttons within their background.

Syntax

<MenuButtonOffset x="10" y="10" />
xThe x-pixel offset from the top left corner of the menu background.
yThe y-pixel offset from the top left corner of the menu background.

Defaults

x0
y0

Notes

  • The menu button size will dictate the size of the background.  The offset*2 will be added to the menu background dimensions.

Elements

TextColor

The color for the text.

Syntax

<TextColor r="255" g="255" b="255"  />
rThe red color value
gThe green color value
bThe blue color value

Defaults

r255
g255
b255

TextOffset

The offset for the text within the EditBox dimensions.  This allows you restrict the text to only the center portion.

Syntax

<TextOffset x="5" y="10" />
xThe x-pixel offset from the top left corner.
yThe y-pixel offset from the top left corner.

Defaults

x0
y0

Notes

  • The offset is The distance subtraced from both the top/bottom and left/right edges of the EditBox.

Window Callbacks

These are the EditBox specific callback events.

Summary
Callbacks
OnTextChangedCalled when the the text inside the edit box changes.

Callbacks

OnTextChanged

Called when the the text inside the edit box changes.

Syntax

SomeComboBox.OnTextChanged( text )
text(wstring) The current text.

Functions

Summary
Functions
EditBoxSetText()Sets the text currently displayed.
EditBoxGetText()Returns the text currently displayed.
EditBoxGetTextLines()Returns the text currently displayed.

Functions

EditBoxSetText()

Sets the text currently displayed.

Parameters

editBoxName(string) The name of the EditBox.
text(wstring) The text string.

Returns

nilno return value

Notes

  • none

Example

TextEditBoxSetText( "LoginWindowUsername", GameData.Account.AccountName )

EditBoxGetText()

Returns the text currently displayed.

Parameters

editBoxName(string) The name of the EditBox.

Returns

text(wstring) The text string.

Notes

  • none

Example

local currText = EditBoxGetText( "SomeEditBox" )

EditBoxGetTextLines()

Returns the text currently displayed.

Parameters

editBoxName(string) The name of the EditBox.

Returns

text(wstring vector) The text string vector.

Notes

  • none

Example

local currText = TextEditBoxGetTextLines( "SomeEditBox" )

Functions

Summary
Functions
EditBoxInsertText()Inserts text at the current cursor location.
EditBoxSetTextColor()Sets the color for the text display.
EditBoxGetTextColor()Returns the current text color for the display.
TextEditBoxSelectAll()Selects all of the text.
EditBoxSetFont()Sets the font for the text display
EditBoxGetFont()Returns the name of the font currently used.
EditBoxGetHistory()Returns the input history for the EditBox.
EditBoxSetHistory()Sets the input history for the edit box.
EditBoxSetHandleKeyDown()Allows you to disable text from automatically being added to the EditBox display when a key is pressed.

Functions

EditBoxInsertText()

Inserts text at the current cursor location.  If any text is currently selected, the inserted text will replace it.

Parameters

editBoxName(string) The name of the EditBox.
text(wstring) The text string to insert.

Returns

nilno return value

Notes

  • none

Example

EditBoxInsertText( "SomeEditBox", someTextToInsert )

EditBoxSetTextColor()

Sets the color for the text display.

Parameters

editBoxName(string) The name of the EditBox.
red(number) The red value for the text color (0-255)
green(number) The green value for the text color (0-255)
blue(number) The blue value for the text color (0-255)

Returns

nil = no return value

Notes

  • none

Example

TextEditBoxSetTextColor ("ChatWindowContainerTextInput", 255, 255, 255)

EditBoxGetTextColor()

Returns the current text color for the display.

Parameters

editBoxName(string) The name of the EditBox.

Returns

red(number) The red value for the text color (0-255)
green(number) The green value for the text color (0-255)
blue(number) The blue value for the text color (0-255)

Notes

  • none

Example

local r, g, b = EditBoxGetTextColor( "SomeEditBox" )

TextEditBoxSelectAll()

Selects all of the text.

Parameters

editBoxName(string) The name of the EditBox.

Returns

nil = no return value

Notes

  • none

Example

TextEditBoxSelectAll ("ChatWindowContainerTextInput" )

EditBoxSetFont()

Sets the font for the text display

Parameters

editBoxName(string) The name of the EditBox.
fontName(number) The name of the font to use.
lineSpacing(number) The line spacing value to use.

Returns

nil = no return value

Related XML

Notes

  • none

Example

EditBoxSetFont( "ChatWindowContainerTextInput", "font_default_text" )

EditBoxGetFont()

Returns the name of the font currently used.

Parameters

editBoxName(string) The name of the EditBox.

Returns

fontName(number) The name of the Font.

Related XML

Notes

  • none

Example

local fontName = EditBoxGetFont("SomeWindow")

EditBoxGetHistory()

Returns the input history for the EditBox.

Parameters

editBoxName(string) The name of the EditBox.

Returns

history(wstring-table) The items in the history.  Index 1 is the most recent item.

Related XML

Notes

  • This command is useful if you wish to save out an input history between instances of an edit box.

Example

EditBoxSetFont( "ChatWindowContainerTextInput", "font_default_text" )

EditBoxSetHistory()

Sets the input history for the edit box.

Parameters

editBoxName(string) The name of the EditBox.
history(wstring-table) The items in the history.  Index 1 is the most recent item.

Returns

nil = no return value

Notes

  • This command is useful if you wish to save out an input history between instances of an edit box.

Example

TextEditBoxSetHistory("ChatWindowContainerTextInput", SystemData.UserInput.ChatHistory )

EditBoxSetHandleKeyDown()

Allows you to disable text from automatically being added to the EditBox display when a key is pressed.

Parameters

editBoxName(string) The name of the EditBox.
handle(boolean) The name of the EditBox.

Returns

history(wstring-table) The items in the history.  Index 1 is the most recent item.

Related XML

Notes

  • This allows you to override the key input mechanism and set your own display for the text.  This is useful for creating a keybinding window.

Example

TextEditBoxSetHandleKeyDown( "KeyMappingWindowTextInput", false )
This element defines a font defintion.
The FullResizeImage allows you to create automatically tiling images to produce backgrounds and frame.
The button element automates generic button functionality, such as swapping texture and font colors automatically according to mouse over and state.
The name of the Font definition to use.