捕获所选 UI 菜单选项的名称 [英] Capture the name of the selected UI menu option

查看:18
本文介绍了捕获所选 UI 菜单选项的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将条目添加到 Google 表格的菜单中:

I'm trying to add entries to the menu of a Google Sheet:

  ui.createMenu('Push to Sheet')
    .addItem('Texas', 'menuItem')
    .addItem('Illinois', 'menuItem')
    .addToUi();

在回调函数menuItem 中,有没有办法捕获所选选项的名称(即'Texas' 或'Illinois')?如果可能,这将作为一个标记来替代无法使用 UI 服务发送参数的情况.

In the callback function menuItem, is there any way to capture the name of the selected option (i.e. 'Texas' or 'Illinois')? If possible, this would serve as a marker to replace the inability to send parameters using the UI service.

推荐答案

不,此信息不会公开.您需要定义特定的函数来处理每个菜单项.

No, this information is not exposed. You'll need to define specific functions to handle each menu item.

例如:

 function texasItem(){
    menuItem('Texas');
 }

 function illinoisItem(){
    menuItem('Illinois');
 }

这篇关于捕获所选 UI 菜单选项的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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