Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Form<"modal">
    • ModalForm

Index

Constructors

  • new ModalForm(data: { components?: { component: ModalComponent; id: string }[]; icon?: string; title?: string }): ModalForm
  • Creates a new modal form with the provided data

    Parameters

    • data: { components?: { component: ModalComponent; id: string }[]; icon?: string; title?: string }

      The data to build the modal form with

      • Optional components?: { component: ModalComponent; id: string }[]

        The components to be displayed and used in the modal form

      • Optional icon?: string

        The texture path to a texture from a resource pack that will be used as this form's icon

      • Optional title?: string

        The title of this form, this is displayed at the top of the window

    Returns ModalForm

Properties

icon?: string

The texture path to a texture from a resource pack that will be used as this form's icon

title: string

The title of this form, this is displayed at the top of the window

type: "modal"

The type of Form

Methods

  • Adds a form component to this modal form

    example
    let modal = new ModalForm({
    title: 'Example Modal Form'
    });

    modal.addComponent('toggleExample', new Toggle({}));

    Parameters

    • id: string

      The id of this component, this will be used in the callback response

    • component: ModalComponent

      The form component to add to this modal form

    Returns void

  • createForm(): ModalFormData
  • removeComponent(id: string): void
  • Removes a form component from this modal form

    example
    let modal = new ModalForm({
    title: 'Example Modal Form'
    });

    modal.removeComponent('toggleExample');

    Parameters

    • id: string

      The id of the component to remove

    Returns void

  • Sends this modal form to a player or array of players

    example
    new ModalForm({
    components: {
    title: 'Example Modal Form',
    icon: 'textures/items/stick',
    components: [
    {
    id: 'sliderId',
    component: new Slider({
    label: 'Example Slider',
    minVal: 10,
    maxVal: 200,
    }),
    },
    {
    id: 'textboxId',
    component: new TextBox({
    label: 'Example Text Field',
    placeholder: 'Example Placeholder Text',
    }),
    },
    ]
    }
    }).send(player, (plr, resp) => {
    plr.sendMessage(Debug.format(resp));
    if (resp.sliderId > 100) plr.sendMessage('Slider value is over 100');
    }, (plr) => {
    plr.sendMessage('Closed modal form via cancelation');
    }, (plr) => {
    plr.sendMessage('Modal form timed out, likely due to having an existing ui open upon request');
    });

    Parameters

    Returns void

  • setDef(curr: any, to: any): any

Generated using TypeDoc version 0.22.18, the 7/5/2022