Returns data about the player results from a modal action form.

Example

actionFormAskFavoriteMonth.ts

import { Player } from '@minecraft/server';
import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';

function askFavoriteMonth(player: Player) {
const form = new ActionFormData()
.title('Months')
.body('Choose your favorite month!')
.button('January')
.button('February')
.button('March')
.button('April')
.button('May');

form.show(player).then((response: ActionFormResponse) => {
if (response.selection === 3) {
player.sendMessage('I like April too!');
} else {
player.sendMessage('Nah, April is the best.');
}
});
}

Hierarchy

Constructors

Properties

cancelationReason?: FormCancelationReason

Remarks

Contains additional details as to why a form was canceled.

canceled: boolean

Remarks

If true, the form was canceled by the player (e.g., they selected the pop-up X close button).

selection?: number

Remarks

Returns the index of the button that was pushed.