Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LabelWidget

Represents a label drawn on the screen, often for help text. The direction can be controlled to make sure the label doesn't get cut off on the edge of the screen.

Hierarchy

Index

Constructors

constructor

Methods

absoluteToLocal

addChild

  • addChild<T>(child: T): T
  • Adds a child widget to this widget. Removes any existing parent from the child first.

    Type parameters

    Parameters

    • child: T

      The child widget

    Returns T

    The child widget

cascadeDraw

  • cascadeDraw(): void
  • Calls the draw() method of this widget and all children widgets recursively. If a widget is disabled it will stop the cascade.

    Returns void

cascadeMouseClick

  • Sends a mouse event through a tree of Widgets. If any widget's onMouseClick returns true, the event will be captured and stop cascading.

    Widgets are called in reverse order, so the last one to render will be the first one called for onMouseClick.

    Parameters

    Returns boolean

cascadeUpdate

  • cascadeUpdate(): void
  • Calls update() for this widget and all children widgets recursively. Children added last will be called last. If a widget is disabled, the update will stop there.

    Returns void

clearMouseContext

  • clearMouseContext(): this

clearUpdateFunc

  • clearUpdateFunc(): this

draw

  • draw(): void
  • Draws on to the given terminal using the widget's current state. Will not draw if disabled.

    Returns void

drawGlyph

getAbsoluteOrigin

getOrigin

getState

isDisabled

  • isDisabled(): boolean

localToAbsolute

mouseClick

onDraw

  • onDraw(): void

onMouseClick

  • Will be fired on click() or cascadeClick(). Return 'true' to capture the event, which will make it no longer cascade to other widgets. Return 'false' to pass the event to other widgets.

    Parameters

    Returns boolean

    boolean - Capture the event

registerMouseContext

removeChild

  • removeChild<T>(child: T): T | undefined
  • Removes a child widget from the parent widget. Clears inherited Terminal/MouseHandler/KeyboardHandler

    Type parameters

    Parameters

    • child: T

      The child widget

    Returns T | undefined

    The child widget if found, undefined otherwise.

setDisabled

  • setDisabled(disabled?: boolean): this
  • Sets the disabled state.

    Parameters

    • Default value disabled: boolean = true

      Default true

    Returns this

    • The Widget

setMouseHandler

  • Sets the mouseHandler for this widget and all children widgets. Will be passed to any children added in the future as well.

    Parameters

    Returns this

    this

setOrigin

  • Sets the local origin of the widget relative to it's parent, then updates the absoluteOrigin of the widget

    Parameters

    • origin: Vector2

      Vector2 - The position relative to its parent

    Returns this

    • The widget

setParent

  • setParent<T>(parent: T): this

setState

setTerminal

  • Sets the terminal for this widget and all children widgets. Will be passed to any children added in the future as well.

    Parameters

    Returns this

    this

setUpdateFunc

update

  • update(): void
  • Calls an updateFunc if previously given, and merges it into the widgets state.

    Returns void

Generated using TypeDoc