Class 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. const ui = DocumentApp.getUi(); const 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 — ปุ่มที่ผู้ใช้คลิก