Skip to content

Class endstone::ModalForm

ClassList > endstone > ModalForm

Represents a modal form with controls.

  • #include <endstone/form/modal_form.h>

Inherits the following classes: endstone::Form

Public Types

Type Name
typedef std::variant< Dropdown, Label, Slider, StepSlider, TextInput, Toggle > Control
typedef std::function< void(Player *, std::string)> OnSubmitCallback

Public Types inherited from endstone::Form

See endstone::Form

Type Name
typedef std::function< void(Player *)> OnCloseCallback

Public Functions

Type Name
ModalForm & addControl (const Control & control)
Adds a control to the form.
std::vector< Control > getControls () const
Gets the controls of the modal form.
std::optional< std::string > getIcon () const
Get the icon of the form.
OnSubmitCallback getOnSubmit () const
Gets the on submit callback of the form.
std::optional< Message > getSubmitButton () const
Gets the submit button text of the form.
ModalForm & setControls (std::vector< Control > controls)
Sets the controls of the modal form.
ModalForm & setIcon (std::optional< std::string > icon)
Sets the icon of the form.
ModalForm & setOnSubmit (OnSubmitCallback on_submit)
Sets the on submit callback of the form.
ModalForm & setSubmitButton (std::optional< Message > text)
Sets the submit button text of the form.

Public Functions inherited from endstone::Form

See endstone::Form

Type Name
Form () = default
OnCloseCallback getOnClose () const
Gets the on close callback of the form.
Message getTitle () const
Gets the title of the form.
T & setOnClose (OnCloseCallback on_close)
Sets the on close callback of the form.
T & setTitle (Message title)
Sets the title of the form.

Protected Attributes inherited from endstone::Form

See endstone::Form

Type Name
OnCloseCallback on_close_
Message title_

Public Types Documentation

typedef Control

using endstone::ModalForm::Control =  std::variant<Dropdown, Label, Slider, StepSlider, TextInput, Toggle>;

typedef OnSubmitCallback

using endstone::ModalForm::OnSubmitCallback =  std::function<void(Player *, std::string)>;

Public Functions Documentation

function addControl

Adds a control to the form.

inline ModalForm & endstone::ModalForm::addControl (
    const Control & control
) 

Parameters:

  • control The control to add to the form.

Returns:

A reference to the current form.


function getControls

Gets the controls of the modal form.

inline std::vector< Control > endstone::ModalForm::getControls () const

Returns:

A list of controls in the modal form.


function getIcon

Get the icon of the form.

inline std::optional< std::string > endstone::ModalForm::getIcon () const

Returns:

The path or URL to the icon file


function getOnSubmit

Gets the on submit callback of the form.

inline OnSubmitCallback endstone::ModalForm::getOnSubmit () const

Returns:

The on submit callback of the form.


function getSubmitButton

Gets the submit button text of the form.

inline std::optional< Message > endstone::ModalForm::getSubmitButton () const

Returns:

The submit button text of the form.


function setControls

Sets the controls of the modal form.

inline ModalForm & endstone::ModalForm::setControls (
    std::vector< Control > controls
) 

Parameters:

  • controls The list of controls to set.

Returns:

A reference to the current form.


function setIcon

Sets the icon of the form.

inline ModalForm & endstone::ModalForm::setIcon (
    std::optional< std::string > icon
) 

Parameters:

  • icon The path or URL to the icon file.

Returns:

A reference to the current form.


function setOnSubmit

Sets the on submit callback of the form.

inline ModalForm & endstone::ModalForm::setOnSubmit (
    OnSubmitCallback on_submit
) 

Parameters:

  • on_submit The callback to be set.

Returns:

A reference to the current form.


function setSubmitButton

Sets the submit button text of the form.

inline ModalForm & endstone::ModalForm::setSubmitButton (
    std::optional< Message > text
) 

Parameters:

  • text The submit button text to set.

Returns:

A reference to the current form.



The documentation for this class was generated from the following file include/endstone/form/modal_form.h