CreateTextField ( x,y,width,height,group[,style] )

Parameters

x,y - position of the field's top-left corner within the group's client area

width,height - size of the field

group - window or gadget group that owns the field

style (optional) - 0: normal (default); bit 1: password field, characters displayed masked

Description

Creates a single-line text field gadget and returns its handle.

The everyday single-line input: an object name in an inspector, a search box, a filename. Read its contents with TextFieldText, set them with SetGadgetText - all text is UTF-8, so any Unicode name works. SetGadgetHint can show grey cue text until the user types something.

Every edit posts a critical gadget-action event ($401) through the shared event queue, and pressing Enter posts one with EventData 13 - which is how you implement commit-on-Enter for a rename field. Use ActivateGadget to drop the keyboard focus straight into the field when a panel opens.

A field that holds only numbers, such as "1.5" or "0, 2, -3", can also be changed without typing: hold Alt (Option on a Mac) over a number and the pointer becomes a left-right arrow, then drag left or right. Each 4 pixels is one step of the number's last decimal place (at most hundredths), or ten steps with Shift held. Every step posts the usual gadget-action event, and releasing the button posts one with EventData 13, as Enter does, so a commit-on-Enter field commits a drag once. Escape during the drag puts the number back. Names, paths and password fields are never dragged.

Style bit 1 turns it into a password field with masked characters. For multi-line input use CreateTextArea instead.

See it working in the world editor shell sample and the native input controls sample.


See also: TextFieldText, SetGadgetText, SetGadgetHint, CreateTextArea, ActivateGadget.

Index