Class: ModalFormResponse
Returns data about player responses to a modal form.
Example
import { Player } from '@minecraft/server';
import { ModalFormData } from '@minecraft/server-ui';
function showExampleModal(player: Player) {
const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r');
modalForm.toggle('Toggle w/o default');
modalForm.toggle('Toggle w/ default', true);
modalForm.slider('Slider w/o default', 0, 50, 5);
modalForm.slider('Slider w/ default', 0, 50, 5, 30);
modalForm.dropdown('Dropdown w/o default', ['option 1', 'option 2', 'option 3']);
modalForm.dropdown('Dropdown w/ default', ['option 1', 'option 2', 'option 3'], 2);
modalForm.textField('Input w/o default', 'type text here');
modalForm.textField('Input w/ default', 'type text here', 'this is default');
modalForm
.show(player)
.then(formData => {
player.sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`);
})
.catch((error: Error) => {
player.sendMessage('Failed to show form: ' + error);
return -1;
});
}
Extends
Constructors
new ModalFormResponse()
private
new ModalFormResponse():ModalFormResponse
Returns
Overrides
Properties
cancelationReason?
optional
readonly
cancelationReason:FormCancelationReason
Remarks
Contains additional details as to why a form was canceled.
Inherited from
FormResponse
. cancelationReason
canceled
readonly
canceled:boolean
Remarks
If true, the form was canceled by the player (e.g., they selected the pop-up X close button).
Inherited from
formValues?
optional
readonly
formValues: (string
|number
|boolean
)[]
Remarks
An ordered set of values based on the order of controls specified by ModalFormData.