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

查看:52
本文介绍了捕获选定的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中,是否可以捕获所选选项的名称(即德克萨斯州"或伊利诺伊州")?如果可能的话,这可以用作标记,以替代无法使用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天全站免登陆