Skip to Content
⚠ Under Construction
ReferenceC++ APIActionForm

endstone::ActionForm

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

Bases: endstone::Form< ActionForm >

Types:

Functions:

NameDescription
ActionForm
addButtonAdds a button to the form.
addDividerAdds a divider to the form.
addHeaderAdds a header to the form.
addLabelAdds a label to the form.
getContentGet the content of the form.
getControlsGet the controls of the action form.
getOnSubmitGets the on submit callback of the form.
setContentSet the content of the form.
setControlsSet the controls of the action form.
setOnSubmitSets 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:

  • 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.

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:

  • text The text of the header

Returns:

A reference to the current form.

addLabel

ActionForm &addLabel(const Message &text)

Adds a label to the form.

Parameters:

  • text The text of the label

Returns:

A reference to the current form.

getContent

Message getContent() const

Get the content of the form.

Returns:

The content of the form.

getControls

const std::vector<Control> &getControls() const

Get the controls of the action form.

Returns:

A list of controls in the action form.

getOnSubmit

OnSubmitCallback getOnSubmit() const

Gets 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:

  • text The 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:

  • controls The 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_submit The callback to be set.

Returns:

A reference to the current form.

Last updated on