endstone::ActionForm
Represents a form with buttons that let the player take action.
Bases: endstone::Form< ActionForm >
Types:
| Name | Description |
|---|---|
Control | |
OnSubmitCallback |
Functions:
| Name | Description |
|---|---|
ActionForm | |
addButton | Adds a button to the form. |
addDivider | Adds a divider to the form. |
addHeader | Adds a header to the form. |
addLabel | Adds a label to the form. |
getContent | Get the content of the form. |
getControls | Get the controls of the action form. |
getOnSubmit | Gets the on submit callback of the form. |
setContent | Set the content of the form. |
setControls | Set the controls of the action form. |
setOnSubmit | Sets the on submit callback of the form. |
Control
using endstone::ActionForm::Control =
std::variant<Button, Divider, Header, Label>; OnSubmitCallback
using endstone::ActionForm::OnSubmitCallback =
std::function<void(Player *, int)>; ActionForm
ActionForm() = default addButton
ActionForm &addButton(const Message &text,
const std::optional<std::string> &icon = std::nullopt,
Button::OnClickCallback on_click = {})Adds a button to the form.
Parameters:
textThe text of the buttoniconThe path or URL to the icon imageon_clickThe on click callback of the button
Returns:
A reference to the current form.
addDivider
ActionForm &addDivider()Adds a divider to the form.
Returns:
A reference to the current form.
addHeader
ActionForm &addHeader(const Message &text)Adds a header to the form.
Parameters:
textThe text of the header
Returns:
A reference to the current form.
addLabel
ActionForm &addLabel(const Message &text)Adds a label to the form.
Parameters:
textThe text of the label
Returns:
A reference to the current form.
getContent
Message getContent() constGet the content of the form.
Returns:
The content of the form.
getControls
const std::vector<Control> &getControls() constGet the controls of the action form.
Returns:
A list of controls in the action form.
getOnSubmit
OnSubmitCallback getOnSubmit() constGets the on submit callback of the form.
Returns:
The on submit callback of the form.
setContent
ActionForm &setContent(Message text)Set the content of the form.
Parameters:
textThe text to set as the content.
Returns:
A reference to the current form.
setControls
ActionForm &setControls(const std::vector<Control> &controls)Set the controls of the action form.
Parameters:
controlsThe list of controls to set.
Returns:
A reference to the current form.
setOnSubmit
ActionForm &setOnSubmit(OnSubmitCallback on_submit)Sets the on submit callback of the form.
Parameters:
on_submitThe callback to be set.
Returns:
A reference to the current form.