列舉代表 alert
或 PromptResponse.getSelectedButton()
傳回的預先決定本地化對話方塊按鈕,指出使用者在對話方塊中點選的按鈕。無法設定這些值。如要在 alert
或 prompt
中新增按鈕,請改用 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.'); }
屬性
屬性 | 類型 | 說明 |
---|---|---|
CLOSE | Enum | 每個對話方塊標題列中顯示的標準關閉按鈕。這個按鈕未明確加入對話方塊,因此無法移除。 |
OK | Enum | 「OK」按鈕,表示應繼續作業。 |
CANCEL | Enum | 顯示「取消」按鈕,表示不應繼續執行作業。 |
YES | Enum | 「是」按鈕,表示對問題有正面回覆。 |
NO | Enum | 「否」按鈕,表示對問題有負面回覆。 |