PixiDom - v1.0.0
    Preparing search index...

    Class Button

    Interactive button component with customizable appearance for different states. Supports bitmap fonts and regular text, backgrounds with colors or textures, and automatic state management for hover and pressed interactions.

    const button = new Button('Click Me', {
    font: 'myFont',
    useBitmapText: true,
    defaultStyle: {
    width: 120,
    height: 40,
    backgroundColor: 0x4a90d9,
    textColor: 0xffffff,
    },
    hoverStyle: {
    width: 120,
    height: 40,
    backgroundColor: 0x357abd,
    textColor: 0xffffff,
    },
    });

    button.onClick(() => console.log('Button clicked!'));
    stage.addChild(button);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    alpha: number
    angle: number
    buttonMode: boolean
    children: DisplayObject[]
    cursor: string
    destroyed?: boolean
    eventMode: EventMode
    height: number
    hitArea:
        | Rectangle
        | RoundedRectangle
        | { contains(x: number, y: number): boolean }
        | null
    inDrag: boolean = false

    Indicates whether the element is currently being dragged

    interactive: boolean
    interactiveChildren: boolean
    isMouseOver: boolean = false

    Indicates whether the mouse/pointer is currently over this element

    mask: DisplayObject | null
    maxSwipeTimeout: number = 300

    Maximum time in milliseconds for a gesture to be considered a swipe

    minSwipeDistance: number = 200

    Minimum distance in pixels for a gesture to be considered a swipe

    parent: Container | null
    pivot: Point
    position: Point
    renderable: boolean
    rotation: number
    scale: Point
    sortableChildren: boolean
    visible: boolean
    width: number
    worldTransform: {
        a: number;
        b: number;
        c: number;
        d: number;
        tx: number;
        ty: number;
    }
    x: number
    y: number
    recomputeDragScalePerMove: boolean = true

    When true (default), each window-level dragmove recomputes the canvas rect and renderer scale via getBoundingClientRect(). This makes drags survive mid-drag canvas resizes, DPR/monitor changes, and CSS-zoom animations without the cursor and element drifting apart.

    Set to false to skip the per-move rect lookup (cache scale once at dragstart). Saves a couple getBoundingClientRect() calls per pointermove — measurable only at very high move rates or with thousands of concurrent draggables.

    Accessors

    • set text(value: string): void

      Sets the button label text.

      Parameters

      • value: string

        New text to display

      Returns void

    • get textSpriteUtilized(): Text | BitmapTextLike | null

      Returns Text | BitmapTextLike | null

    Methods

    • Centers this element both horizontally and vertically within its parent container.

      Returns void

    • Parameters

      • Optionaloptions: boolean | { baseTexture?: boolean; children?: boolean; texture?: boolean }

      Returns void

    • Parameters

      • event: string
      • ...args: unknown[]

      Returns boolean

    • Parameters

      • event: string
      • Optionalfn: EventListener
      • Optionalcontext: unknown

      Returns this

    • Parameters

      • event: string
      • fn: EventListener
      • Optionalcontext: unknown

      Returns this

    • Parameters

      • event: string
      • fn: EventListener
      • Optionalcontext: unknown

      Returns this

    • Forces a complete redraw of the button including background and text.

      Returns void

    • Parameters

      • OptionalbeginIndex: number
      • OptionalendIndex: number

      Returns DisplayObject[]

    • Parameters

      • position: { x: number; y: number }
      • Optionalpoint: Point

      Returns Point

    • Parameters

      • position: { x: number; y: number }
      • Optionalfrom: DisplayObject
      • Optionalpoint: Point

      Returns Point