Torque3D Documentation / _generateds / GuiTextEditCtrl

GuiTextEditCtrl

consoledoc.h

A component that places a text entry box on the screen.

More...

Text Input

string

Script command to be called when the first validater is lost.

string

Script command to be called when the Escape key is pressed.

int

How large of a history buffer to maintain.

bool

If true, when the 'tab' key is pressed, it will act as if the Enter key was pressed on the control.

If the attempted text cannot be entered, this sound effect will be played.

bool

If true, every key event will act as if the Enter key was pressed.

bool

If true, all characters entered will be stored in the control, however will display as the character stored in passwordMask.

string

If 'password' is true, this is the character that will be used to mask the characters in the control.

Callbacks

void
onTabComplete(string val)

Called if tabComplete is true, and the 'tab' key is pressed.

void

Called when the 'Return' or 'Enter' key is pressed.

void

Called whenever the control is validated.

Public Attributes

caseString

The text to show on the control.

Public Functions

void

Unselects all selected text in the control.

void

Force a validation to occur.

int

Returns the current position of the text cursor in the control.

string

Acquires the current text displayed in this control.

void
invalidText(bool playSound)

Trigger the invalid sound and make the box red.nn.

bool

Checks to see if all text in the control has been selected.

bool

Returns if the text is set to valid or not.n@Return true if text is set to valid, false if not.nn.

void

Selects all text within the control.

void
setCursorPos(int position)

Sets the text cursor at the defined position within the control.

void
setText(string text)

Sets the text in the control.

void

Restores the box to normal color.nn.

Detailed Description

A component that places a text entry box on the screen.

Fonts and sizes are changed using profiles. The text value can be set or entered by a user.

 new GuiTextEditCtrl(MessageHud_Edit)
{
    text = "Hello World";
    validate = "validateCommand();"
    escapeCommand = "escapeCommand();";
    historySize = "5";
    tabComplete = "true";
    deniedSound = "DeniedSoundProfile";
    sinkAllKeyEvents = "true";
    password = "true";
    passwordMask = "*";
     //Properties not specific to this control have been omitted from this example.
 };

Text Input

string validate 

Script command to be called when the first validater is lost.

string escapeCommand 

Script command to be called when the Escape key is pressed.

int historySize 

How large of a history buffer to maintain.

bool tabComplete 

If true, when the 'tab' key is pressed, it will act as if the Enter key was pressed on the control.

SFXTrack deniedSound 

If the attempted text cannot be entered, this sound effect will be played.

bool sinkAllKeyEvents 

If true, every key event will act as if the Enter key was pressed.

bool password 

If true, all characters entered will be stored in the control, however will display as the character stored in passwordMask.

string passwordMask 

If 'password' is true, this is the character that will be used to mask the characters in the control.

Callbacks

onTabComplete(string val)

Called if tabComplete is true, and the 'tab' key is pressed.

Parameters:

val

Input to mimick the '1' sent by the actual tab key button press.

// Tab key has been pressed, causing the callback to occur.
GuiTextEditCtrl::onTabComplete(%this,%val)
  {
     //Code to run when the onTabComplete callback occurs
  }

onReturn()

Called when the 'Return' or 'Enter' key is pressed.

// Return or Enter key was pressed, causing the callback to occur.
GuiTextEditCtrl::onReturn(%this)
  {
     // Code to run when the onReturn callback occurs
  }

onValidate()

Called whenever the control is validated.

// The control gets validated, causing the callback to occur
GuiTextEditCtrl::onValidated(%this)
  {
     // Code to run when the control is validated
  }

Public Attributes

caseString placeholderText 

The text to show on the control.

Public Functions

clearSelectedText()

Unselects all selected text in the control.

// Inform the control to unselect all of its selected text
%thisGuiTextEditCtrl.clearSelectedText();

forceValidateText()

Force a validation to occur.

// Inform the control to force a validation of its text.
%thisGuiTextEditCtrl.forceValidateText();

getCursorPos()

Returns the current position of the text cursor in the control.

// Acquire the cursor position in the control
%position = %thisGuiTextEditCtrl.getCursorPost();

return:

Text cursor position within the control.

getText()

Acquires the current text displayed in this control.

// Acquire the value of the text control.
%text = %thisGuiTextEditCtrl.getText();

return:

The current text within the control.

invalidText(bool playSound)

Trigger the invalid sound and make the box red.nn.

Parameters:

playSound

Play the invalid text sound or not.n

isAllTextSelected()

Checks to see if all text in the control has been selected.

// Check to see if all text has been selected or not.
%allSelected = %thisGuiTextEditCtrl.isAllTextSelected();

return:

True if all text in the control is selected, otherwise false.

isValidText()

Returns if the text is set to valid or not.n@Return true if text is set to valid, false if not.nn.

selectAllText()

Selects all text within the control.

// Inform the control to select all of its text.
%thisGuiTextEditCtrl.selectAllText();

setCursorPos(int position)

Sets the text cursor at the defined position within the control.

Parameters:

position

Text position to set the text cursor.

// Define the cursor position
%position = "12";

// Inform the GuiTextEditCtrl control to place the text cursor at the defined position
%thisGuiTextEditCtrl.setCursorPos(%position);

setText(string text)

Sets the text in the control.

Parameters:

text

Text to place in the control.

// Define the text to display
%text = "Text!"

// Inform the GuiTextEditCtrl to display the defined text
%thisGuiTextEditCtrl.setText(%text);

validText()

Restores the box to normal color.nn.