Preparing search index...

    Layout manager arranging widgets in a row or column.

        const root = new Widget(parent);
    const mainLayout = new BoxLayout();
    mainLayout.setDirection(Direction.TopToBottom);
    mainLayout.spacing = 12;
    root.layout = mainLayout;

    // Section 1: Vertical layout (TopToBottom)
    const sec1 = new Label(root);
    sec1.text = '1. Direction.TopToBottom';
    sec1.fontRole = FontRole.TitleBold;
    mainLayout.addWidget(sec1);

    const vBox = new Widget(root);
    const vLayout = new BoxLayout();
    vLayout.setDirection(Direction.TopToBottom);
    vLayout.spacing = 4;
    vBox.layout = vLayout;
    for (const t of ['First', 'Second', 'Third']) {
    const l = new Label(vBox);
    l.text = ` ${t}`;
    vLayout.addWidget(l);
    }
    mainLayout.addWidget(vBox);

    // Section 2: Horizontal layout (LeftToRight)
    const sec2 = new Label(root);
    sec2.text = '2. Direction.LeftToRight';
    sec2.fontRole = FontRole.TitleBold;
    mainLayout.addWidget(sec2);

    const hBox = new Widget(root);
    const hLayout = new BoxLayout();
    hLayout.setDirection(Direction.LeftToRight);
    hLayout.spacing = 8;
    hBox.layout = hLayout;
    for (const t of ['A', 'B', 'C']) {
    const btn = new PushButton(hBox);
    btn.text = t;
    hLayout.addWidget(btn);
    }
    mainLayout.addWidget(hBox);

    // Section 3: Spacing and margins
    const sec3 = new Label(root);
    sec3.text = '3. Spacing & Margins';
    sec3.fontRole = FontRole.TitleBold;
    mainLayout.addWidget(sec3);

    const spacedBox = new Widget(root);
    spacedBox.setContentsMargins(16, 8, 16, 8);
    spacedBox.autoFillBackground = true;
    (spacedBox as any).backgroundRole = BackgroundRole.ComponentBackground;
    const spacedLayout = new BoxLayout();
    spacedLayout.setDirection(Direction.LeftToRight);
    spacedLayout.spacing = 16;
    spacedBox.layout = spacedLayout;
    const spacedLabel = new Label(spacedBox);
    spacedLabel.text = 'spacing=16, margins=(16,8)';
    spacedLayout.addWidget(spacedLabel);
    mainLayout.addWidget(spacedBox);

    // Section 4: Nested layouts
    const sec4 = new Label(root);
    sec4.text = '4. Nested Layouts';
    sec4.fontRole = FontRole.TitleBold;
    mainLayout.addWidget(sec4);

    const nested = new Widget(root);
    const outerLayout = new BoxLayout();
    outerLayout.setDirection(Direction.LeftToRight);
    outerLayout.spacing = 8;
    nested.layout = outerLayout;

    const leftCol = new BoxLayout();
    leftCol.setDirection(Direction.TopToBottom);
    const l1 = new Label(nested);
    l1.text = 'Left 1';
    leftCol.addWidget(l1);
    const l2 = new Label(nested);
    l2.text = 'Left 2';
    leftCol.addWidget(l2);
    outerLayout.addLayout(leftCol);

    const rightCol = new BoxLayout();
    rightCol.setDirection(Direction.TopToBottom);
    const r1 = new Label(nested);
    r1.text = 'Right 1';
    rightCol.addWidget(r1);
    const r2 = new Label(nested);
    r2.text = 'Right 2';
    rightCol.addWidget(r2);
    outerLayout.addLayout(rightCol);

    mainLayout.addWidget(nested);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    enabled: boolean

    Whether the layout is active and responsive to user input.

    isNull: boolean

    Whether this object references a valid layout.

    spacing: number

    Distance between widgets in the layout.

    Methods

    • Adds a child layout to this BoxLayout. The child layout is appended in the current direction (left-to-right or top-to-bottom).

      Parameters

      Returns void

    • Adds a stretch space (spacer) with the specified stretch factor. Higher stretch values take more available space proportionally. Default factor is 0 (fixed space).

      Parameters

      • stretch: number

      Returns void

    • Adds a widget to the layout with an optional stretch factor and alignment. The stretch determines how much space the widget claims; alignment controls its position within its allocated space.

      Parameters

      Returns void

    • Schedule layout for deletion after event processing.

      Returns void

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object refers to the same instance as the given object.

      Parameters

      Returns boolean

    • Set the margins around layout contents.

      Parameters

      • left: number
      • top: number
      • right: number
      • bottom: number

      Returns void

    • Sets the layout direction (LeftToRight, RightToLeft, TopToBottom, BottomToTop). Controls whether widgets are arranged horizontally or vertically.

      Parameters

      Returns void