Class CvsPanel

This class represents a draggable panel that can be used to hold other controls.

On creation the panel -

  1. has an opaque background (this is required for dragging).
  2. can be dragged in both X and Y directions.
  3. is constrained so the entire panel stays within the display area.

If the background is transparent then the panel cannot be dragged. Panel movement can limited using the draggable() and constrain() methods.

It is recommended that the panel width and height should not exceed that of the display area (i.e. canvas).

Hierarchy

  • CvsBufferedControl
    • CvsPanel

Accessors

  • get id(): string
  • The unique identifier for this control.

    Returns string

  • get isDraggable(): boolean
  • True if the panel can be dragged else false.

    Returns boolean

  • get isEnabled(): boolean
  • This is true if the control can respond to UI events else false.

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

    Returns boolean

  • get isOpaque(): boolean
  • This is true if the control background is opaque else false.

    Use opaque() and transparent() display / hide the background.

    Returns boolean

  • get isVisible(): boolean
  • This is true if the control is visible else false.

    Use hide() and show() to set visibility.

    Returns boolean

  • get type(): string
  • The type name for this control.
    (type name = class name without the Cvs prefix)

    Returns string

Methods

  • 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 id

    • Optional rx: number
    • Optional ry: number

    Returns any

  • Panel position can be constrained horizontally and vertically so that it fits within the outside the display area.

    Returns

    this control

    Parameters

    • limitX: boolean = true
    • limitY: boolean = true

    Returns CvsPanel

  • Get or set the corner radii used for this control.

    To set the radii the parameters must be one of the following

    • an array of 4 numbers.
    • a comma seperated list of 4 numbers.
    • a single number to be used for all 4 radii.

    If no parameter is passed or does not match one of the above then an array of the currently used radii values.

    Returns

    an array of the currently used radii values

    Parameters

    • Rest ...c: any

      valid radii combination

    Returns number[] | CvsBaseControl

  • Disables this control.

    Returns

    this control

    Parameters

    • Optional cascade: boolean

      if true disable child controls

    Returns CvsBaseControl

  • Horizontal and vertical movement can be restricted based on the actual parameters. If either parameter is true then then the panel is considered 'draggable'.

    Returns

    this control

    Parameters

    • allowX: boolean = true

      allow horizontal movement if true

    • allowY: boolean = true

      allow vertical movement if true

    Returns CvsPanel

  • Enables this control.

    Returns

    this control

    Parameters

    • Optional cascade: boolean

      if true enable child controls

    Returns CvsBaseControl

  • Make this control invisible.

    Returns

    this control

    Parameters

    • Optional cascade: boolean

      if true hide children

    Returns CvsBaseControl

  • Move this control relative to current position.

    Returns

    this control

    Parameters

    • x: number

      horizontal distance

    • y: number

      vertical distance

    Returns CvsPanel

  • Move this control to an absolute position.

    Returns

    this control

    Parameters

    • x: number

      horizontal position

    • y: number

      vertical position

    Returns CvsPanel

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

    The second parameter, alpha, is optional and controls the level of opaqueness from 0 - transparent to 255 - fully opaque (efault value).

    Returns

    this control

    Parameters

    • alpha: number = 255

      alpha value for controls background color.

    Returns CvsBaseControl

  • Remove a child control from this one so that it stays in same screen position.

    Returns

    this control

    Parameters

    Returns CvsPanel

  • If the name of a valid color scheme is provided then it will use it to display the control, non-existant scheme names will be ignored. In both cases this control is returned.

    If there is no parameter it returns the name of the current color scheme used by this control.

    Returns

    this control or the control's color scheme

    Parameters

    • Optional name: string

      the color scheme name e.g. 'blue'

    • Optional cascade: boolean

      if true propogate scheme to all child controls.

    Returns ColorScheme | CvsBaseControl

  • This sets the event handler to be used when this control fires an event. The parameter can take one of 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 control's events.

    Returns CvsPanel

  • 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

  • Makes the controls background fully transparent.

    Returns

    this control

    Returns CvsBaseControl

Generated using TypeDoc