Bitbybit Docs
    Preparing search index...

    Class BabylonGuiControl

    What every GUI control shares, whatever its kind: padding, alignment inside its parent, size, color, font size, visibility, the enabled and read-only states and cloning. Sizes are pixel strings such as 200px or fractions of the parent from 0 to 1. The setters change the control in place and give it back so calls can be chained.

    Index

    Constructors

    create

    • Makes a copy of a control with all its settings, names it and adds it to container when one is given; host is the GUI texture the copy belongs to.

      Parameters

      • inputs: CloneControlDto

        The control, the optional container, the name and the optional host texture

      Returns Control

      The copy

      const second = bitbybit.babylon.gui.control.cloneControl({ control: button, container: panel, name: "second", host: ui });
      
    • Passes through the name of a control event, such as a pointer click or pointer enter, as a typed selector for code that subscribes to control events by name.

      Parameters

      Returns controlObservableSelectorEnum

      The same selector

      const selector = bitbybit.babylon.gui.control.createControlObservableSelector({ selector: Bit.Inputs.BabylonGui.controlObservableSelectorEnum.onPointerClickObservable });
      

    get

    • Finds a control by its name inside a container, searching its children too.

      Parameters

      Returns Control

      The control with that name

      const button = bitbybit.babylon.gui.control.getControlByName({ container: panel, name: "buttonName" });
      
    • Reads the height of a control, as a pixel string or a fraction of the parent.

      Parameters

      Returns string | number

      The height

    • Reads the width of a control, as a pixel string or a fraction of the parent.

      Parameters

      Returns string | number

      The width

    • Reads the main color of a control as a CSS color string.

      Parameters

      Returns string

      The color

    • Reads the font size of a control's text, as a string such as 24px or a number of pixels.

      Parameters

      Returns string | number

      The font size

    • Reads whether a control is shown rather than hidden.

      Parameters

      Returns boolean

      True when the control is visible

    • Reads whether a control ignores input while still being shown normally.

      Parameters

      Returns boolean

      True when the control is read-only

    • Reads whether a control is enabled rather than dimmed and inactive.

      Parameters

      Returns boolean

      True when the control is enabled

    positioning

    • Sets the space kept clear around a control inside its parent, per side; a side left out keeps its padding. Values are pixel strings such as 10px or fractions of the parent.

      Parameters

      Returns Control

      The same control

      bitbybit.babylon.gui.control.changeControlPadding({ control: button, paddingLeft: "10px", paddingRight: "10px", paddingTop: "4px", paddingBottom: "4px" });
      
    • Sets where a control sits inside its parent: left, center or right, and top, center or bottom.

      Parameters

      • inputs: AlignmentDto<Control>

        The control and the two alignments

      Returns Control

      The same control

      bitbybit.babylon.gui.control.changeControlAlignment({ control: panel, horizontalAlignment: Bit.Inputs.BabylonGui.horizontalAlignmentEnum.left, verticalAlignment: Bit.Inputs.BabylonGui.verticalAlignmentEnum.top });
      

    set

    • Shows or hides a control; a hidden control keeps its place in a stack panel's layout.

      Parameters

      Returns Control

      The same control

    • Makes a control read-only or editable again; a read-only control is shown normally but ignores input.

      Parameters

      Returns Control

      The same control

    • Enables or disables a control; a disabled control is drawn dimmed and ignores input.

      Parameters

      Returns Control

      The same control

    • Sets the height of a control, as a pixel string such as 40px or a fraction of the parent from 0 to 1.

      Parameters

      Returns Control

      The same control

    • Sets the width of a control, as a pixel string such as 200px or a fraction of the parent from 0 to 1.

      Parameters

      Returns Control

      The same control

    • Sets the main color of a control, the text color of a button or text block and the fill color of a slider or checkbox, as a CSS color.

      Parameters

      Returns Control

      The same control

    • Sets the font size of a control's text, as a number of pixels or a string such as 24px.

      Parameters

      Returns Control

      The same control