Enum Button

  • TheButton enum represents predetermined, localized dialog buttons returned byalert orPromptResponse.getSelectedButton() to indicate which button a user clicked.

  • These button values cannot be set directly; useButtonSet to add buttons to an alert or prompt.

  • To call an enum, you use its parent class, name, and property, such asBase.Button.CLOSE.

Button

An enum representing predetermined, localized dialog buttons returned by analert orPromptResponse.getSelectedButton() to indicatewhich button in a dialog the user clicked. These values cannot be set; to add buttons to analert orprompt, useButtonSet instead.

To call an enum, you call its parent class, name, and property. For example,Base.Button.CLOSE.

// Display a dialog box with a message and "Yes" and "No" buttons.constui=DocumentApp.getUi();constresponse=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.');}

Properties

PropertyTypeDescription
CLOSEEnumThe standard close button displayed in every dialog's title bar. This button is not explicitlyadded to a dialog, and it cannot be removed.
OKEnumAn "OK" button, indicating that an operation should proceed.
CANCELEnumA "Cancel" button, indicating that an operation should not proceed.
YESEnumA "Yes" button, indicating a positive response to a question.
NOEnumA "No" button, indicating a negative response to a question.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.