Class CvsTextField

This class supports a single line text entry field.

The user must ensure that the field is wide enough for the maximum length of text expected. This control stops accepting input if it is likely to exceed the control width.

The left/right arrow keys move the text insertion point within the text. Used in combination with the shift key enables part or all of the text to be selected.

If no text is selected then the arrows keys can move off the current control to another. This only works if each textfield has a unique index number.

If the control has the index value 'idx' then the next control depends on the arrow key pressed -
left : idx - 1
right : idx + 1
up : idx - offset
down : idx + offset

The offset value is set when initialising the idx value with the index(idx, deltaIndex method.)

No other controls can be used while a textfield control is active. Pressing 'Enter' or attempting to move to a non-existant textfield deactivates the current text field.

The user can provide their own validation function which is checked when the control is deativated.

Since

0.9.3

Hierarchy

Properties

_clock: number
_currCsrIdx: number = 0
_cursorOn: boolean = false
_linkIndex: number
_linkOffset: number = 0
_prevCsrIdx: number = 0
_textInvalid: boolean = false
_validation: Function
action: Function = ...

The event handler for this control. Although it is permitted to set this property directly it is recommended that the setAction(...) method is used to define the event handler actions.

Methods

  • Called when this control passes focus to a new control.

    Parameters

    • offset: number

    Returns void

  • Add a child to this control using its relative position [rx, ry]. If rx and ry are not provided then it uses the values set in the child.

    Returns

    this control

    Parameters

    • c: string | CvsBaseControl

      is the actual control or its name

    • Optional rx: number
    • Optional ry: number

    Returns any

  • Clears the validity flag irrespective of whether the text is valid or not.

    Returns

    this control

    Returns CvsTextField

  • Set or get the corner radii used for this control

    Returns

    an array with the 4 corner radii

    Parameters

    • c: number[]

      an array of 4 corner radii

    Returns number[] | CvsBaseControl

  • Disables this control

    Returns

    this control

    Parameters

    • Optional cascade: boolean

      if true disable child controls

    Returns CvsBaseControl

  • Enables this control

    Returns

    this control

    Parameters

    • Optional cascade: boolean

      if true enable child controls

    Returns CvsBaseControl

  • Calculates the absolute position on the canvas taking into account any ancestors

    Returns

    the actual position in the canvas

    Returns __Position

  • If there is no text then this method will always return false. If there is some text then this method returns the same as the isValid() method.

    Returns

    true if there is some text and it passed any validation function

    Returns boolean

  • Make this control invisible

    Returns

    this control

    Parameters

    • Optional cascade: boolean

      if true hide children

    Returns CvsBaseControl

  • Set a unique index number for this text field.

    Returns

    this control

    Parameters

    • idx: number

      unique index number

    • Optional deltaIndex: number

      relative link when using up/down arrow keys

    Returns CvsTextField

  • Use enable() and disable() to enable and disable it.

    Returns

    true if the control is enabled else false

    Returns boolean

  • If there is no validation function then this will always return true.

    Returns

    true if the text has passed validation

    Returns boolean

  • Returns

    true if this control is visible

    Since

    0.9.3

    Returns boolean

  • Returns

    the unique identier for this control

    Returns string

  • Makes the controls background opaque. The actual color depends on the controls color scheme

    Returns

    this control

    Returns CvsBaseControl

  • Specify the orientation to show this control

    Returns

    this control

    Parameters

    • dir: string

      'north', 'south', 'east' or 'west'

    Returns CvsBaseControl

  • Adds this control to another control which becomes its parent

    Returns

    this control

    Parameters

    • p: string | CvsBaseControl

      is the parental control or its name

    • Optional rx: number

      x position relative to parent

    • Optional ry: number

      y position relative to parent

    Returns CvsBaseControl

  • Sets or gets the color scheme used by this control.

    Returns

    this control or the control's color scheme

    Parameters

    • Optional id: string
    • Optional cascade: boolean

    Returns CvsBaseControl | __Scheme

  • This sets the event handler to be used when this control fires an event. The parameter can take three forms:

    1. Arrow function definition
    2. Anonymous function definition
    3. Named function declaration

    Returns

    this control

    Parameters

    • event_handler: Function

      the function to handle this controls event

    Returns CvsTextField

  • Make this control visible

    Returns

    this control

    Parameters

    • Optional cascade: boolean

      if true show children

    Returns CvsBaseControl

  • Shrink the control to fit contents.

    To shrink on one dimension only pass either 'w' (width) or 'h' (height) to indicate which dimmension to shrink

    Returns

    this control

    Parameters

    • Optional dim: string

      the dimension to shrink

    Returns CvsBaseControl

  • Gets or sets the current text. Any EOL characters are stripped out of the string. If necessary the string length will be reduced until will fit inside the textfiel. If a validation function has been set then the string will be validated.

    Returns

    this control for setter

    Parameters

    • Optional t: string

      a string representing text to display

    Returns string | CvsTextField

  • Sets the text alignment.

    Processing constants are used to define the text alignment.

    Returns

    this control

    Parameters

    • align: number

      LEFT, CENTER or RIGHT

    Returns CvsBaseControl

  • Sets or gets the text size.

    Returns

    this control or the current text size

    Parameters

    • lts: number

      the text size to use

    Returns number | GUI | CvsTextField

  • Sets the size of the text to use in the tooltip

    Parameters

    • Optional tsize: number

      text size for this tooltip

    Returns CvsTextField

  • Create a tooltip for this control

    Returns

    this control

    Parameters

    • tiptext: string

      the text to appear in the tooltip

    • duration: number

      how long the tip remains visible (milliseconds)

    Returns CvsTextField

  • Force the control to validate

    Returns

    this control

    Returns CvsTextField

  • Uesr provide a validation function for this textfield

    Returns

    this control

    Parameters

    • vfunc: Function

      the validation function

    Returns CvsTextField

Generated using TypeDoc