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()는 사용자가 응답 텍스트가 유효하도록 의도했는지 확인하는 데 도움이 될 수 있습니다.

리턴

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


getSelectedButton()

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

리턴

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