Class: MessageFormResponse
Returns data about the player results from a modal message form.
Example
import { Player } from '@minecraft/server';
import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
function showMessage(player: Player) {
const messageForm = new MessageFormData()
.title({ translate: 'permissions.removeplayer' }) // "Remove player"
.body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] }) // "Player 1 or Player 2"
.button1('Player 1')
.button2('Player 2');
messageForm
.show(player)
.then((formData: MessageFormResponse) => {
// player canceled the form, or another dialog was up and open.
if (formData.canceled || formData.selection === undefined) {
return;
}
player.sendMessage(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
})
.catch((error: Error) => {
player.sendMessage('Failed to show form: ' + error);
});
}
Extends
Constructors
new MessageFormResponse()
private
new MessageFormResponse():MessageFormResponse
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
selection?
optional
readonly
selection:number
Remarks
Returns the index of the button that was pushed.