列舉代表預先決定的本地化組合,包含可新增至 alert
或 prompt
的對話方塊按鈕組合。如要判斷使用者點選了哪個按鈕,請使用 Button
。
如要呼叫列舉,您可以呼叫其父項類別、名稱和屬性。例如
Base.ButtonSet.OK
。
// 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.'); }
屬性
屬性 | 類型 | 說明 |
---|---|---|
OK | Enum | 一個「確定」按鈕,表示只能關閉的資訊訊息。 |
OK_CANCEL | Enum | 「OK」按鈕和「取消」按鈕,可讓使用者繼續執行或停止作業。 |
YES_NO | Enum | 「是」按鈕和「否」按鈕,可讓使用者回答是非題。 |
YES_NO_CANCEL | Enum | 「是」按鈕、「否」按鈕和「取消」按鈕,可讓使用者回答是非題或停止作業。 |