为Google Apps脚本中的Spreadsheet App Modal对话框捕获onClose事件 [英] Capture onClose event for Spreadsheet App Modal Dialog in Google Apps Script

查看:127
本文介绍了为Google Apps脚本中的Spreadsheet App Modal对话框捕获onClose事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当模态对话框(使用 showModalDialog() )已从电子表格应用程序中关闭.

I want to do something when the Modal Dialog (opened using showModalDialog()) is closed from the Spreadsheet App.

但是,我在Google提供的API文档中找不到此类事件的引用. 我发现了如何在警报框中捕获此事件,并且通过使用这段代码,我可以捕获用户如何关闭警报框,但是我不能在模态对话框"或无模式对话框"中使用它.

However I cannot find the reference of such event, in the API documents provided by Google. I found how to capture this event in a Alert Box, and by using this piece of code I can capture how the user closed the Alert Box, but I cannot use this in a Modal Dialog or a Modeless Dialog.

有没有办法做到这一点?请回答.

Is there a way to do this? Please kindly answer if you do.

推荐答案

不可能.您应该以一种无关紧要的方式编写脚本.例如,通过在对话框中显示一个大的操作按钮,使用户清楚他必须单击该位置才能继续执行脚本.

This is not possible. And you should write your script in a way that this does not matter. For example, by showing a big action button in the dialog, making it clear to the user that he must click there for the script to continue.

但是,如果您真的想做到这一点,我想您可以使用 HtmlService 对话框,该对话框会定期对后端进行异步调用,并且每个调用都会在退出前等待下一个调用,然后,如果下一个"调用未及时到达,则可以假定该对话框已关闭并执行关闭过程而不是简单地退出.

But if you really want to make this happen, I guess you could use an HtmlService dialog that make regular async calls to the backend and each call waits for the next one before quitting, then if the "next" call does not get in time, it can assume the dialog got closed and execute your close procedure instead of simply quitting.

这篇关于为Google Apps脚本中的Spreadsheet App Modal对话框捕获onClose事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆