Capture the name of the selected UI menu option

我与影子孤独终老i 提交于 2020-01-06 05:25:14

问题


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();

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.


回答1:


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

eg:

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

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


来源:https://stackoverflow.com/questions/51827523/capture-the-name-of-the-selected-ui-menu-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!