Skip to content

Class endstone::ActionForm

ClassList > endstone > ActionForm

Represents a form with buttons that let the player take action.

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

Inherits the following classes: endstone::Form

Public Types

Type Name
typedef std::variant< Button, Divider, Header, Label > Control
typedef std::function< void(Player *, int)> OnSubmitCallback

Public Types inherited from endstone::Form

See endstone::Form

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

Public Functions

Type Name
ActionForm () = default
ActionForm & addButton (const Message & text, const std::optional< std::string > & icon=std::nullopt, Button::OnClickCallback on_click={})
Adds a button to the form.
ActionForm & addDivider ()
Adds a divider to the form.
ActionForm & addHeader (const Message & text)
Adds a header to the form.
ActionForm & addLabel (const Message & text)
Adds a label to the form.
Message getContent () const
Get the content of the form.
const std::vector< Control > & getControls () const
Get the controls of the action form.
OnSubmitCallback getOnSubmit () const
Gets the on submit callback of the form.
ActionForm & setContent (Message text)
Set the content of the form.
ActionForm & setControls (const std::vector< Control > & controls)
Set the controls of the action form.
ActionForm & setOnSubmit (OnSubmitCallback on_submit)
Sets the on submit callback 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::ActionForm::Control =  std::variant<Button, Divider, Header, Label>;

typedef OnSubmitCallback

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

Public Functions Documentation

function ActionForm

explicit endstone::ActionForm::ActionForm () = default

function addButton

Adds a button to the form.

inline ActionForm & endstone::ActionForm::addButton (
    const Message & text,
    const std::optional< std::string > & icon=std::nullopt,
    Button::OnClickCallback on_click={}
) 

Parameters:

  • text The text of the button
  • icon The path or URL to the icon image
  • on_click The on click callback of the button

Returns:

A reference to the current form.


function addDivider

Adds a divider to the form.

inline ActionForm & endstone::ActionForm::addDivider () 

Returns:

A reference to the current form.


function addHeader

Adds a header to the form.

inline ActionForm & endstone::ActionForm::addHeader (
    const Message & text
) 

Parameters:

  • text The text of the header

Returns:

A reference to the current form.


function addLabel

Adds a label to the form.

inline ActionForm & endstone::ActionForm::addLabel (
    const Message & text
) 

Parameters:

  • text The text of the label

Returns:

A reference to the current form.


function getContent

Get the content of the form.

inline Message endstone::ActionForm::getContent () const

Returns:

The content of the form.


function getControls

Get the controls of the action form.

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

Returns:

A list of controls in the action form.


function getOnSubmit

Gets the on submit callback of the form.

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

Returns:

The on submit callback of the form.


function setContent

Set the content of the form.

inline ActionForm & endstone::ActionForm::setContent (
    Message text
) 

Parameters:

  • text The text to set as the content.

Returns:

A reference to the current form.


function setControls

Set the controls of the action form.

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

Parameters:

  • controls The list of controls to set.

Returns:

A reference to the current form.


function setOnSubmit

Sets the on submit callback of the form.

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

Parameters:

  • on_submit The callback to be set.

Returns:

A reference to the current form.



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