表示由 alert
或 PromptResponse.getSelectedButton()
返回的预定本地化对话框按钮的枚举,用于指示用户点击了对话框中的哪个按钮。无法设置这些值;要向 alert
或 prompt
添加按钮,请改用 ButtonSet
。
// Display a dialog box with a message and "Yes" and "No" buttons. var ui = DocumentApp.getUi(); var response = ui.alert('Are you sure you want to continue?', ui.ButtonSet.YES_NO); // Process the user's response. if (response == ui.Button.YES) { Logger.log('The user clicked "Yes."'); } else { Logger.log('The user clicked "No" or the dialog\'s close button.'); }
属性
属性 | 类型 | 说明 |
---|---|---|
CLOSE | Enum | 每个对话框的标题栏中都会显示标准关闭按钮。此按钮未显式添加到对话框中,因此无法移除。 |
OK | Enum | 一个“确定”按钮,表示操作应继续。 |
CANCEL | Enum | 一个“取消”按钮,表示操作不应继续。 |
YES | Enum | 一个“是”按钮,表示对问题的积极回答。 |
NO | Enum | “否”按钮,表示对问题的否定回答。 |