问题
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