The TextBox class represents a text box control.
// create our own class derived from form
class MyForm extends Form
{
var m_text1;
var m_text2;
function MyForm()
{
super("Simple Entry", 100, 100, 200, 150);
// create a text control
m_text1 = new TextBox("", 5, 5, 180, 24);
this.add(m_text1);
// in m_text1, handle the event that fires when
// the text is changed, so we can mirror the text
// in m_text2 (this demonstrates the textChanged event)
m_text1.textChanged.connect(this, onTextChanged);
// create another text control
m_text2 = new TextBox("", 5, 35, 180, 24);
this.add(m_text2);
var b = new Button("Exit", 60, 75, 80, 24);
this.add(b);
b.click.connect(this, onButtonClicked);
}
function onTextChanged(sender, params)
{
// set the text in the second control to the text
// in the first control that has been changed
m_text2.setText(params.text);
}
function onButtonClicked()
{
// exit the event loop
Application.exit();
}
}
// create an instance of our derived MyForm class
// and show it
var f = new MyForm;
f.show();
f = null;
// start the event loop
Application.run();
Appends the text, specified by text, to the the existing text of the textbox.
Clears the textbox of all text.
Returns the insertion point for the textbox.
Returns the insertion point for the textbox, which is the position in the textbox text where the cursor is located and the index where text will be inserted.
Returns the number of lines in the textbox.
Returns the number of lines in the textbox. If the textbox is not a multiline textbox, the function returns 1.
Returns the number of characters on a line.
Returns the number of characters on a given line in the textbox.
Returns the string of text on a given line.
Gets the text on line, specified by line, and returns the the text as a string.
Returns the maximum number of characters the textbox can have.
Returns the maximum number of characters the textbox can have. If the textbox doesn't have a maximum length, the function returns 0.
Returns true if the password mode is on for the textbox, and false otherwise.
When a textbox is in password mode, the text is substituted with a non-descript character such as an asterisk so that the text can't be read. This function returns true if password mode is on for the textbox, and false if the password mode is off.
Returns the selected text in the textbox.
Gets the selected text in the textbox and returns it as a string.
Returns the text of the textbox.
Gets the text of the textbox.
Returns true if the textbox multiline mode is on and false if it is turned off.
Returns true if the textbox multiline mode is on and false if it is turned off.
Selects text in the textbox, starting at the position specified by index and continuing for the number of characters specified by count.
Selects all the text in the textbox.
Sets the insertion point in the textbox to the offset given by index. The insertion point is the position in the textbox text where the cursor is located and the index where text will be inserted.
Sets the maximum number of characters the textbox can have to length.
Sets the multiline mode of the textbox. If flag is true, then the textbox multiline mode will be turned on, causing the textbox text to wrap. If flag is false, then the textbox multiple mode will be turned off, so that the textbox text will not wrap.
When a textbox is in password mode, the text is substituted with a non-descript character such as an asterisk so that the text can't be read. This function turns the password mode on if flag is true and off if flag is false.
Sets the text for the textbox from text.