Class PromptResponse

PromptResponse

Google 앱의 사용자 인터페이스 환경에 표시되는 prompt 대화상자에 대한 응답입니다. 응답에는 사용자가 대화상자의 입력란에 입력한 모든 텍스트가 포함되며 사용자가 대화상자를 닫기 위해 클릭한 버튼이 표시됩니다.

// 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()

사용자가 대화상자의 입력란에 입력한 텍스트를 가져옵니다. 사용자가 'Cancel'과 같이 부정적인 음의 버튼을 클릭하거나 대화상자의 제목 표시줄에 있는 닫기 버튼을 클릭하여 대화상자를 닫아도 텍스트를 사용할 수 있습니다. getSelectedButton()는 사용자가 응답 텍스트의 유효성을 의도한지 확인하는 데 도움이 될 수 있습니다.

Return

String: 사용자가 대화상자의 입력란에 입력한 텍스트입니다.


getSelectedButton()

사용자가 클릭하여 대화상자를 닫는 버튼을 가져옵니다. 사용자가 모든 대화상자의 제목 표시줄에 포함된 닫기 버튼을 클릭하면 이 메서드는 Button.CLOSE를 반환합니다.

Return

Button — 사용자가 클릭한 버튼입니다.