Enum Button

Button

ennum แสดงปุ่มแปลที่กําหนดไว้ล่วงหน้าซึ่งแสดงโดย 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.');
}

พร็อพเพอร์ตี้

พร็อพเพอร์ตี้ประเภทคำอธิบาย
CLOSEEnumปุ่มปิดมาตรฐานที่แสดงในแถบชื่อกล่องโต้ตอบทุกกล่อง ปุ่มนี้ไม่ได้เพิ่มลงในกล่องโต้ตอบอย่างชัดเจนและนําออกไม่ได้
OKEnumปุ่ม "OK" บ่งชี้ว่าการดําเนินการควรจะดําเนินการต่อไป
CANCELEnumปุ่ม "Cancel" ระบุว่าการดําเนินการไม่ควรเกิดขึ้น
YESEnumปุ่ม A "Yes" ซึ่งระบุคําตอบเชิงบวกสําหรับคําถาม
NOEnumปุ่ม "No" ซึ่งระบุการตอบสนองเชิงลบต่อคําถาม