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.'); }
メソッド
| メソッド | 戻り値の型 | 概要 |
|---|---|---|
get | String | ユーザーがダイアログの入力フィールドに入力したテキストを取得します。 |
get | Button | ユーザーがダイアログを閉じるためにクリックしたボタンを取得します。 |
詳細なドキュメント
getResponseText()
ユーザーがダイアログの入力フィールドに入力したテキストを取得します。ユーザーが [キャンセル] などの否定的な意味合いのボタンや、ダイアログのタイトルバーにある閉じるボタンをクリックしてダイアログを閉じた場合でも、テキストは利用できます。getSelectedButton() は、ユーザーがレスポンス テキストを有効にすることを意図したかどうかを判断するのに役立ちます。
戻る
String - ユーザーがダイアログの入力フィールドに入力したテキスト。
getSelectedButton()
ユーザーがダイアログを閉じるためにクリックしたボタンを取得します。ユーザーがすべてのダイアログのタイトルバーに含まれている閉じるボタンをクリックした場合、このメソッドは Button.CLOSE を返します。
戻る
Button - ユーザーがクリックしたボタン。