Package Win32::GUI::Textfield

Back to the Packages


Constructor

new Win32::GUI::Textfield(PARENT, %OPTIONS)

Creates a new Textfield object; can also be called as PARENT->AddTextfield(%OPTIONS). Class specific %OPTIONS are:

  -align         => left/center/right (default left)
      aligns the text in the control accordingly.
  -keepselection => 0/1 (default 0)
      the selection is not hidden when the control loses focus.
  -multiline     => 0/1 (default 0)
      the control can have more than one line (note that newline
      is "\r\n", not "\n"!).
  -password      => 0/1 (default 0)
      masks the user input (like password prompts).
  -passwordchar  => char (default '*')
      the char that is shown instead of the text with -password => 1.
  -prompt        => (see below)
  -readonly      => 0/1 (default 0)
      text can't be changed.

The -prompt option is very special; if a string is passed, a Win32::GUI::Label object (with text set to the string passed) is created to the left of the Textfield. Example:

    $Window->AddTextfield(
        -name   => "Username",
        -left   => 75,
        -top    => 150,
        -prompt => "Your name:",
    );

Furthermore, the value to -prompt can be a reference to a list containing the string and an additional parameter, which sets the width for the Label (eg. [ STRING, WIDTH ] ). If WIDTH is negative, it is calculated relative to the Textfield left coordinate. Example:

    -left => 75,                          (Label left) (Textfield left)
    -prompt => [ "Your name:", 30 ],       75           105 (75+30)
    -left => 75,
    -prompt => [ "Your name:", -30 ],      45 (75-30)   75

Note that the Win32::GUI::Label object is named like the Textfield, with a ``_Prompt'' suffix (in the example above, the Label is named ``Username_Prompt'').


Methods

Append(TEXT)

[TBD]

LineFromChar(INDEX)

[TBD]

MaxLength([CHARS])

[TBD]

Modified([FLAG])

[TBD]

PasswordChar([CHAR])

[TBD]

ReadOnly([FLAG])

[TBD]

ReplaceSel(STRING, [FLAG])

[TBD]

Scroll(COMMAND | LINE | HORIZONTAL, VERTICAL)

[TBD]

Select(START, END)

Selects the specified range of characters.

SelectAll()

[TBD]

Selection()

[TBD]

Undo()

[TBD]


Events

Change()

Sent when the text in the field is changed by the user.

GotFocus()

Sent when the control is activated.

LostFocus()

Sent when the control is deactivated.