Capture the name of the selected UI menu option

2019-01-29 09:49发布

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条回答
乱世女痞
2楼-- · 2019-01-29 10:33

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');
 }
查看更多
登录 后发表回答