Class PromptResponse

PromptResponse

การตอบกลับกล่องโต้ตอบ prompt ที่แสดงในสภาพแวดล้อมอินเทอร์เฟซผู้ใช้สำหรับแอป Google การตอบสนองจะประกอบด้วยข้อความที่ผู้ใช้ป้อนในช่องป้อนข้อมูลของกล่องโต้ตอบ และระบุว่าผู้ใช้คลิกปุ่มใดเพื่อปิดกล่องโต้ตอบ

// Display a dialog box with a title, message, input field, and "Yes" and "No" buttons. The
// user can also close the dialog by clicking the close button in its title bar.
var ui = DocumentApp.getUi();
var response = ui.prompt('Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO);

// Process the user's response.
if (response.getSelectedButton() == ui.Button.YES) {
  Logger.log('The user\'s name is %s.', response.getResponseText());
} else if (response.getSelectedButton() == ui.Button.NO) {
  Logger.log('The user didn\'t want to provide a name.');
} else {
  Logger.log('The user clicked the close button in the dialog\'s title bar.');
}

วิธีการ

วิธีการประเภทการแสดงผลรายละเอียดแบบย่อ
getResponseText()Stringรับข้อความที่ผู้ใช้ป้อนในช่องป้อนข้อมูลของกล่องโต้ตอบ
getSelectedButton()Buttonรับปุ่มที่ผู้ใช้คลิกเพื่อปิดกล่องโต้ตอบ

เอกสารประกอบโดยละเอียด

getResponseText()

รับข้อความที่ผู้ใช้ป้อนในช่องป้อนข้อมูลของกล่องโต้ตอบ ข้อความจะแสดงขึ้นแม้ว่าผู้ใช้จะปิดกล่องโต้ตอบด้วยการคลิกปุ่มที่มีความหมายโดยนัยในเชิงลบ เช่น "ยกเลิก" หรือปุ่ม "ปิด" ในแถบชื่อกล่องโต้ตอบ getSelectedButton() สามารถช่วยตัดสินว่าผู้ใช้มีเจตนาให้ข้อความตอบกลับถูกต้องหรือไม่

รีเทิร์น

String — ข้อความที่ผู้ใช้ป้อนในช่องป้อนข้อมูลของกล่องโต้ตอบ


getSelectedButton()

รับปุ่มที่ผู้ใช้คลิกเพื่อปิดกล่องโต้ตอบ หากผู้ใช้คลิกปุ่มปิดที่รวมอยู่ในแถบชื่อของกล่องโต้ตอบทุกแถบ เมธอดนี้จะแสดง Button.CLOSE

รีเทิร์น

Button — ปุ่มที่ผู้ใช้คลิก