For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server-ui/classes/ActionFormResponse.md.

Class: ActionFormResponse

Beta

返回来自模态操作表单的玩家结果数据。

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

Examples

showActionForm.ts
showFavoriteMonth.ts
import { world, DimensionLocation } from '@minecraft/server';
import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';

function showActionForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
  const playerList = world.getPlayers();

  if (playerList.length >= 1) {
    const form = new ActionFormData()
      .title('Test Title')
      .body('Body text here!')
      .button('btn 1')
      .button('btn 2')
      .button('btn 3')
      .button('btn 4')
      .button('btn 5');

    form.show(playerList[0]).then((result: ActionFormResponse) => {
      if (result.canceled) {
        log('Player exited out of the dialog. Note that if the chat window is up, dialogs are automatically canceled.');
        return -1;
      } else {
        log('Your result was: ' + result.selection);
      }
    });
  }
}

Extends

Properties

cancelationReason?

readonly optional cancelationReason?: FormCancelationReason

Beta

Remarks

包含关于表单为何被取消的附加详细信息。

Contains additional details as to why a form was canceled.

Inherited from

FormResponse.cancelationReason


canceled

readonly canceled: boolean

Beta

Remarks

如果为 true,则表示表单已被玩家取消(例如,他们点击了弹窗的 X 关闭按钮)。

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

Inherited from

FormResponse.canceled


selection?

readonly optional selection?: number

Beta

Remarks

返回被按下的按钮的索引。

Returns the index of the button that was pushed.