Class 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. 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 - ユーザーがクリックしたボタン。