Enum Button

按鈕

列舉代表 alertPromptResponse.getSelectedButton() 傳回的預先決定本地化對話方塊按鈕,指出使用者在對話方塊中點選的按鈕。無法設定這些值。如要在 alertprompt 中新增按鈕,請改用 ButtonSet

如要呼叫列舉,您可以呼叫其父項類別、名稱和屬性。例如 Base.Button.CLOSE

// 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.');
}

屬性

屬性類型說明
CLOSEEnum每個對話方塊標題列中顯示的標準關閉按鈕。這個按鈕未明確加入對話方塊,因此無法移除。
OKEnum「OK」按鈕,表示應繼續作業。
CANCELEnum顯示「取消」按鈕,表示不應繼續執行作業。
YESEnum「是」按鈕,表示對問題有正面回覆。
NOEnum「否」按鈕,表示對問題有負面回覆。