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

Classes

Type Name
class Button
Represents a button with text and an optional icon.

Public Types

Type Name
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.
const std::vector< Button > & getButtons () const
Get the buttons of the action form.
Message getContent () const
Get the content of the form.
OnSubmitCallback getOnSubmit () const
Gets the on submit callback of the form.
ActionForm & setButtons (const std::vector< Button > & buttons)
Set the buttons of the action form.
ActionForm & setContent (Message text)
Set the content of the 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 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 getButtons

Get the buttons of the action form.

inline const std::vector< Button > & endstone::ActionForm::getButtons () const

Returns:

A list of buttons in the action form.


function getContent

Get the content of the form.

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

Returns:

The content of the 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 setButtons

Set the buttons of the action form.

inline ActionForm & endstone::ActionForm::setButtons (
    const std::vector< Button > & buttons
) 

Parameters:

  • buttons The list of buttons to set.

Returns:

A reference to the current 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 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