A user interface control for displaying and editing the text value of an object. Synchronizes with the target object's string value by executing specified getter and setter functions. Creates (or uses an existing) text input element to display and edit the text.

Because this is an Observer, you can connect it to a Subject; when the Subject broadcasts events, this will update the value it displays.

Hierarchy (view full)

Implements

Constructors

  • Parameters

    • label: string

      the text shown in a label next to the text input area

    • getter: (() => string)

      function that returns the target value

        • (): string
        • Returns string

    • setter: ((value) => void)

      function to change the target value

        • (value): void
        • Parameters

          • value: string

          Returns void

    • Optional textField: HTMLInputElement

      the text field to use; if not provided, then a text input field is created.

    Returns TextControlBase

Properties

columns_: number = 40

The number of columns (characters) shown in the text field.

firstClick_: boolean = false

True when first click in field after gaining focus.

getter_: (() => string)

function that returns the current target value

Type declaration

    • (): string
    • function that returns the current target value

      Returns string

label_: string

the name shown in a label next to the textField

lastValue_: string = ''

The last value that the text field was set to, used to detect when user has intentionally changed the value.

setter_: ((value) => void)

function to change the target value

Type declaration

    • (value): void
    • function to change the target value

      Parameters

      • value: string

      Returns void

textField_: HTMLInputElement

the text field showing the double value

value_: string

The value of the target as last seen by this control;

Methods

  • Returns width of the text input field (number of characters).

    Returns number

    the width of the text input field.

  • Returns the top level Element of this control. For example, this might be a label Element that encloses an input Element.

    Returns HTMLElement

    the top level Element of this control

  • Returns the value of this control (which should match the target value if observe is being called).

    Returns string

    the value of this control

  • Notifies this Observer that a change has occurred in the Subject.

    Parameters

    • _event: SubjectEvent

      contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter

    Returns void

  • Changes the value shown by this control, and sets the target to this value.

    Parameters

    • value: string

      the new value

    Returns void

    Throws

    if value is not a string

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

  • Checks that an entered number is a valid number, updates the target value if valid; if an exception occurs then shows an alert and restores the old value.

    Parameters

    • _event: Event

      the event that caused this callback to fire

    Returns void

Generated using TypeDoc