endstone/form

Classes

NameDescription
ActionFormRepresents a form with buttons that let the player take action.
ButtonRepresents a button with text and an optional icon.
DividerRepresents a divider.
DropdownRepresents a dropdown with a set of predefined options.
FormRepresents a generic form.
HeaderRepresents a header with a label.
LabelRepresents a text label.
MessageFormRepresents a form with two buttons.
ModalFormRepresents a modal form with controls.
SliderRepresents a slider with a label.
StepSliderRepresents a step slider with a set of predefined options.
TextInputRepresents a text input field.
ToggleRepresents a toggle button with a label.

classActionForm

Defined in <endstone/form/action_form.h>

Bases: Form<ActionForm>

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

Type Aliases

Methods

NameDescription
ActionForm
getContentGet the content of the form.
setContentSet the content of the form.
addButtonAdds a button to the form.
addLabelAdds a label to the form.
addHeaderAdds a header to the form.
addDividerAdds a divider to the form.
getControlsGet the controls of the action form.
setControlsSet the controls of the action form.
getOnSubmitGets the on submit callback of the form.
setOnSubmitSets the on submit callback of the form.

typeControl

typeOnSubmitCallback

std::function<void(Player*, int)> OnSubmitCallback

methActionFormexplicit

ActionForm() =default

methgetContentconst

Message getContent() const

Get the content of the form.

Returns

TypeDescription
MessageThe content of the form.

methsetContent

ActionForm& setContent(Message text)

Set the content of the form.

Parameters

NameTypeDescription
textMessageThe text to set as the content.

Returns

TypeDescription
ActionForm&A reference to the current form.

methaddButton

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

Adds a button to the form.

Parameters

NameTypeDescription
textconst Message&The text of the button
iconconst std::optional<std::string>&The path or URL to the icon image
on_clickButton::OnClickCallbackThe on click callback of the button

Returns

TypeDescription
ActionForm&A reference to the current form.

methaddLabel

ActionForm& addLabel(const Message& text)

Adds a label to the form.

Parameters

NameTypeDescription
textconst Message&The text of the label

Returns

TypeDescription
ActionForm&A reference to the current form.

methaddHeader

ActionForm& addHeader(const Message& text)

Adds a header to the form.

Parameters

NameTypeDescription
textconst Message&The text of the header

Returns

TypeDescription
ActionForm&A reference to the current form.

methaddDivider

ActionForm& addDivider()

Adds a divider to the form.

Returns

TypeDescription
ActionForm&A reference to the current form.

methgetControlsconst

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

Get the controls of the action form.

Returns

TypeDescription
const std::vector<Control>&A list of controls in the action form.

methsetControls

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

Set the controls of the action form.

Parameters

NameTypeDescription
controlsconst std::vector<Control>&The list of controls to set.

Returns

TypeDescription
ActionForm&A reference to the current form.

methgetOnSubmitconst

OnSubmitCallback getOnSubmit() const

Gets the on submit callback of the form.

Returns

TypeDescription
OnSubmitCallbackThe on submit callback of the form.

methsetOnSubmit

ActionForm& setOnSubmit(OnSubmitCallback on_submit)

Sets the on submit callback of the form.

Parameters

NameTypeDescription
on_submitOnSubmitCallbackThe callback to be set.

Returns

TypeDescription
ActionForm&A reference to the current form.

classButton

Defined in <endstone/form/controls/button.h>

Represents a button with text and an optional icon.

Type Aliases

NameDescription
OnClickCallback

Methods

NameDescription
Button
Button
getTextGets the text of the button.
setTextSets the text of the button.
getIconGet the icon of the button.
setIconSets the icon for the button.
getOnClickGets the on click callback of the button.
setOnClickSets the on click callback of the button.

typeOnClickCallback

std::function<void(Player*)> OnClickCallback

methButton

Button() =default

methButtonexplicit

Button(Message text, std::optional<std::string> icon = std::nullopt, OnClickCallback on_click = {})

methgetTextconst

Message getText() const

Gets the text of the button.

Returns

TypeDescription
MessageThe text.

methsetText

Button& setText(Message text)

Sets the text of the button.

Parameters

NameTypeDescription
textMessageThe new text for the button.

Returns

TypeDescription
Button&A reference to the current button.

methgetIconconst

std::optional<std::string> getIcon() const

Get the icon of the button.

Returns

TypeDescription
std::optional<std::string>The path or URL to the icon file

methsetIcon

Button& setIcon(std::string icon)

Sets the icon for the button.

Parameters

NameTypeDescription
iconstd::stringThe path or URL to the icon file.

Returns

TypeDescription
Button&A reference to the current button.

methgetOnClickconst

OnClickCallback getOnClick() const

Gets the on click callback of the button.

Returns

TypeDescription
OnClickCallbackThe on click callback of the button.

methsetOnClick

Button& setOnClick(OnClickCallback on_click)

Sets the on click callback of the button.

Parameters

NameTypeDescription
on_clickOnClickCallbackThe callback to be set.

Returns

TypeDescription
Button&A reference to the current button.

classDivider

Defined in <endstone/form/controls/divider.h>

Represents a divider.

Methods

NameDescription
Divider

methDivider

Divider() =default

Defined in <endstone/form/controls/dropdown.h>

Represents a dropdown with a set of predefined options.

Methods

NameDescription
Dropdown
Dropdown
getLabelGets the label of the dropdown.
setLabelSets the label of the dropdown.
addOptionAdds a new option to the dropdown.
getOptionsGets the options of the dropdown.
setOptionsSets the options of the dropdown.
getDefaultIndexGets the default index of the dropdown.
setDefaultIndexSets the default index of the dropdown.
Dropdown() =default
Dropdown(Message label, std::vector<std::string> options, std::optional<int> default_index = std::nullopt)
Message getLabel() const

Gets the label of the dropdown.

Returns

TypeDescription
MessageThe label of the dropdown.
Dropdown& setLabel(Message label)

Sets the label of the dropdown.

Parameters

NameTypeDescription
labelMessageThe new label for the dropdown.

Returns

TypeDescription
Dropdown&A reference to the dropdown itself.
Dropdown& addOption(const std::string& option)

Adds a new option to the dropdown.

Parameters

NameTypeDescription
optionconst std::string&The new option for the dropdown.

Returns

TypeDescription
Dropdown&A reference to the dropdown itself.
std::vector<std::string> getOptions() const

Gets the options of the dropdown.

Returns

TypeDescription
std::vector<std::string>The options of the dropdown.
Dropdown& setOptions(std::vector<std::string> options)

Sets the options of the dropdown.

Parameters

NameTypeDescription
optionsstd::vector<std::string>The new options for the dropdown.

Returns

TypeDescription
Dropdown&A reference to the dropdown itself.
std::optional<int> getDefaultIndex() const

Gets the default index of the dropdown.

Returns

TypeDescription
std::optional<int>The default index of the dropdown.
Dropdown& setDefaultIndex(std::optional<int> default_index)

Sets the default index of the dropdown.

Parameters

NameTypeDescription
default_indexstd::optional<int>The new default index for the dropdown.

Returns

TypeDescription
Dropdown&A reference to the dropdown itself.

classForm

Defined in <endstone/form/form.h>

Represents a generic form.

The Form class provides a base abstraction for different types of forms. It supports three types of forms: Action, Message, and Modal. Each form has a title, which can be a string or a translatable object.

Type Aliases

NameDescription
OnCloseCallback

Variables

NameDescription
title_
on_close_

Methods

NameDescription
Form
getTitleGets the title of the form.
setTitleSets the title of the form.
setOnCloseSets the on close callback of the form.
getOnCloseGets the on close callback of the form.

typeOnCloseCallback

std::function<void(Player*)> OnCloseCallback

vartitle_protected

Message title_

varon_close_protected

OnCloseCallback on_close_

methFormexplicit

Form() =default

methgetTitleconst

Message getTitle() const

Gets the title of the form.

Returns

TypeDescription
MessageThe title of the form.

methsetTitle

T& setTitle(Message title)

Sets the title of the form.

Parameters

NameTypeDescription
titleMessageThe title of the form to be set.

Returns

TypeDescription
T&A reference to the current form.

methsetOnClose

T& setOnClose(OnCloseCallback on_close)

Sets the on close callback of the form.

Parameters

NameTypeDescription
on_closeOnCloseCallbackThe callback to be set.

Returns

TypeDescription
T&A reference to the current form.

methgetOnCloseconst

OnCloseCallback getOnClose() const

Gets the on close callback of the form.

Returns

TypeDescription
OnCloseCallbackThe on close callback of the form.

Defined in <endstone/form/controls/header.h>

Represents a header with a label.

Methods

NameDescription
Header
Header
getLabelGets the label of the header.
setLabelSets the label of the header.

methHeader

Header() =default

methHeaderexplicit

Header(Message label)

methgetLabelconst

Message getLabel() const

Gets the label of the header.

Returns

TypeDescription
MessageThe label of the header.

methsetLabel

Header& setLabel(Message label)

Sets the label of the header.

Parameters

NameTypeDescription
labelMessageThe new label for the header.

Returns

TypeDescription
Header&A reference to the current header.

classLabel

Defined in <endstone/form/controls/label.h>

Represents a text label.

Methods

NameDescription
Label
Label
getTextGets the text of the label.
setTextSets the text of the label.

methLabel

Label() =default

methLabelexplicit

Label(Message text)

methgetTextconst

Message getText() const

Gets the text of the label.

Returns

TypeDescription
MessageThe text of the label.

methsetText

Label& setText(Message text)

Sets the text of the label.

Parameters

NameTypeDescription
textMessageThe new text for the label.

Returns

TypeDescription
Label&A reference to the current label.

classMessageForm

Defined in <endstone/form/message_form.h>

Bases: Form<MessageForm>

Represents a form with two buttons.

Type Aliases

NameDescription
OnSubmitCallback

Methods

NameDescription
getContentGet the content of the form.
setContentSet the content of the form.
getButton1Get the text of button1.
setButton1Set the text of button1.
getButton2Get the text of button2.
setButton2Set the text of button2.
getOnSubmitGets the on submit callback of the form.
setOnSubmitSets the on submit callback of the form.

typeOnSubmitCallback

std::function<void(Player*, int)> OnSubmitCallback

methgetContentconst

Message getContent() const

Get the content of the form.

Returns

TypeDescription
MessageThe content of the form.

methsetContent

MessageForm& setContent(Message text)

Set the content of the form.

Parameters

NameTypeDescription
textMessageThe text to set as the content.

Returns

TypeDescription
MessageForm&A reference to the current form.

methgetButton1const

Message getButton1() const

Get the text of button1.

Returns

TypeDescription
MessageThe text of button1.

methsetButton1

MessageForm& setButton1(Message text)

Set the text of button1.

Parameters

NameTypeDescription
textMessageThe text to set as the button1 text.

Returns

TypeDescription
MessageForm&A reference to the current form.

methgetButton2const

Message getButton2() const

Get the text of button2.

Returns

TypeDescription
MessageThe text of button2.

methsetButton2

MessageForm& setButton2(Message text)

Set the text of button2.

Parameters

NameTypeDescription
textMessageThe text to set as the button2 text.

Returns

TypeDescription
MessageForm&A reference to the current form.

methgetOnSubmitconst

OnSubmitCallback getOnSubmit() const

Gets the on submit callback of the form.

Returns

TypeDescription
OnSubmitCallbackThe on submit callback of the form.

methsetOnSubmit

MessageForm& setOnSubmit(OnSubmitCallback on_submit)

Sets the on submit callback of the form.

Parameters

NameTypeDescription
on_submitOnSubmitCallbackThe callback to be set.

Returns

TypeDescription
MessageForm&A reference to the current form.

classModalForm

Defined in <endstone/form/modal_form.h>

Bases: Form<ModalForm>

Represents a modal form with controls.

Type Aliases

Methods

NameDescription
addControlAdds a control to the form.
getControlsGets the controls of the modal form.
setControlsSets the controls of the modal form.
getSubmitButtonGets the submit button text of the form.
setSubmitButtonSets the submit button text of the form.
getIconGet the icon of the form.
setIconSets the icon of the form.
getOnSubmitGets the on submit callback of the form.
setOnSubmitSets the on submit callback of the form.

typeControl

typeOnSubmitCallback

std::function<void(Player*, std::string)> OnSubmitCallback

methaddControl

ModalForm& addControl(const Control& control)

Adds a control to the form.

Parameters

NameTypeDescription
controlconst Control&The control to add to the form.

Returns

TypeDescription
ModalForm&A reference to the current form.

methgetControlsconst

std::vector<Control> getControls() const

Gets the controls of the modal form.

Returns

TypeDescription
std::vector<Control>A list of controls in the modal form.

methsetControls

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

Sets the controls of the modal form.

Parameters

NameTypeDescription
controlsstd::vector<Control>The list of controls to set.

Returns

TypeDescription
ModalForm&A reference to the current form.

methgetSubmitButtonconst

std::optional<Message> getSubmitButton() const

Gets the submit button text of the form.

Returns

TypeDescription
std::optional<Message>The submit button text of the form.

methsetSubmitButton

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

Sets the submit button text of the form.

Parameters

NameTypeDescription
textstd::optional<Message>The submit button text to set.

Returns

TypeDescription
ModalForm&A reference to the current form.

methgetIconconst

std::optional<std::string> getIcon() const

Get the icon of the form.

Returns

TypeDescription
std::optional<std::string>The path or URL to the icon file

methsetIcon

Sets the icon of the form.

Parameters

NameTypeDescription
iconstd::optional<std::string>The path or URL to the icon file.

Returns

TypeDescription
ModalForm&A reference to the current form.

methgetOnSubmitconst

OnSubmitCallback getOnSubmit() const

Gets the on submit callback of the form.

Returns

TypeDescription
OnSubmitCallbackThe on submit callback of the form.

methsetOnSubmit

ModalForm& setOnSubmit(OnSubmitCallback on_submit)

Sets the on submit callback of the form.

Parameters

NameTypeDescription
on_submitOnSubmitCallbackThe callback to be set.

Returns

TypeDescription
ModalForm&A reference to the current form.

classSlider

Defined in <endstone/form/controls/slider.h>

Represents a slider with a label.

Methods

NameDescription
Slider
Slider
getLabelGets the label of the toggle.
setLabelSets the label of the toggle.
getMinGets the minimum value of the slider.
setMinSets the minimum value of the slider.
getMaxGets the maximum value of the slider.
setMaxSets the maximum value of the slider.
getStepGets the step size of the slider.
setStepSets the step size of the slider.
getDefaultValueGets the default value of the slider.
setDefaultValueSets the default value of the slider.

methSlider

Slider() =default

methSliderexplicit

Slider(Message label, float min, float max, float step, std::optional<float> default_value = std::nullopt)

methgetLabelconst

Message getLabel() const

Gets the label of the toggle.

Returns

TypeDescription
MessageThe label of the toggle.

methsetLabel

Slider& setLabel(Message label)

Sets the label of the toggle.

Parameters

NameTypeDescription
labelMessageThe new label for the toggle.

Returns

TypeDescription
Slider&A reference to the current toggle.

methgetMinconst

float getMin() const

Gets the minimum value of the slider.

Returns

TypeDescription
floatThe minimum value of the slider.

methsetMin

Slider& setMin(float min)

Sets the minimum value of the slider.

Parameters

NameTypeDescription
minfloatThe new minimum value for the slider.

Returns

TypeDescription
Slider&A reference to the current slider, for function chaining.

methgetMaxconst

float getMax() const

Gets the maximum value of the slider.

Returns

TypeDescription
floatThe maximum value of the slider.

methsetMax

Slider& setMax(float max)

Sets the maximum value of the slider.

Parameters

NameTypeDescription
maxfloatThe new maximum value for the slider.

Returns

TypeDescription
Slider&A reference to the current slider, for function chaining.

methgetStepconst

float getStep() const

Gets the step size of the slider.

Returns

TypeDescription
floatThe step size of the slider.

methsetStep

Slider& setStep(float step)

Sets the step size of the slider.

Parameters

NameTypeDescription
stepfloatThe new step size for the slider.

Returns

TypeDescription
Slider&A reference to the current slider, for function chaining.

methgetDefaultValueconst

std::optional<float> getDefaultValue() const

Gets the default value of the slider.

Returns

TypeDescription
std::optional<float>The default value of the slider.

methsetDefaultValue

Slider& setDefaultValue(std::optional<float> default_value)

Sets the default value of the slider.

Parameters

NameTypeDescription
default_valuestd::optional<float>The new default value for the slider.

Returns

TypeDescription
Slider&A reference to the current slider, for function chaining.

classStepSlider

Defined in <endstone/form/controls/step_slider.h>

Bases: Dropdown

Represents a step slider with a set of predefined options.

Methods

NameDescription
Dropdown
Dropdown

methDropdown

Dropdown() =default

methDropdownexplicit

Dropdown(Message label, std::vector<std::string> options, std::optional<int> default_index = std::nullopt)

classTextInput

Defined in <endstone/form/controls/text_input.h>

Represents a text input field.

Methods

NameDescription
TextInput
TextInput
getLabelGets the label of the text input field.
setLabelSets the label of the text input field.
getPlaceholderGets the placeholder of the text input field.
setPlaceholderSets the placeholder of the text input field.
getDefaultValueGets the default text of the text input field.
setDefaultValueSets the default text of the text input field.

methTextInput

TextInput() =default

methTextInputexplicit

TextInput(Message label, Message placeholder, std::optional<std::string> default_text = std::nullopt)

methgetLabelconst

Message getLabel() const

Gets the label of the text input field.

Returns

TypeDescription
MessageThe label of the text input field.

methsetLabel

TextInput& setLabel(Message label)

Sets the label of the text input field.

Parameters

NameTypeDescription
labelMessageThe new label for the text input field.

Returns

TypeDescription
TextInput&A reference to the text input field itself.

methgetPlaceholderconst

Message getPlaceholder() const

Gets the placeholder of the text input field.

Returns

TypeDescription
MessageThe placeholder of the text input field.

methsetPlaceholder

TextInput& setPlaceholder(Message placeholder)

Sets the placeholder of the text input field.

Parameters

NameTypeDescription
placeholderMessageThe new placeholder for the text input field.

Returns

TypeDescription
TextInput&A reference to the text input field itself.

methgetDefaultValueconst

std::optional<std::string> getDefaultValue() const

Gets the default text of the text input field.

Returns

TypeDescription
std::optional<std::string>The default text of the text input field.

methsetDefaultValue

TextInput& setDefaultValue(std::optional<std::string> text)

Sets the default text of the text input field.

Parameters

NameTypeDescription
textstd::optional<std::string>The new default text for the text input field.

Returns

TypeDescription
TextInput&A reference to the text input field itself.

classToggle

Defined in <endstone/form/controls/toggle.h>

Represents a toggle button with a label.

Methods

NameDescription
Toggle
Toggle
getLabelGets the label of the toggle.
setLabelSets the label of the toggle.
getDefaultValueGets the default value of the toggle.
setDefaultValueSets the default value of the toggle.

methToggle

Toggle() =default

methToggleexplicit

Toggle(Message label, bool default_value = false)

methgetLabelconst

Message getLabel() const

Gets the label of the toggle.

Returns

TypeDescription
MessageThe label of the toggle.

methsetLabel

Toggle& setLabel(Message label)

Sets the label of the toggle.

Parameters

NameTypeDescription
labelMessageThe new label for the toggle.

Returns

TypeDescription
Toggle&A reference to the current toggle.

methgetDefaultValueconst

bool getDefaultValue() const

Gets the default value of the toggle.

Returns

TypeDescription
boolThe default value of the toggle.

methsetDefaultValue

Toggle& setDefaultValue(bool value)

Sets the default value of the toggle.

Parameters

NameTypeDescription
valueboolThe new default value for the toggle.

Returns

TypeDescription
Toggle&A reference to the current toggle.

On this page