选择单元格时触发函数

Trigger a function on selecting a cell

如何编写每次用户选择任何单元格时都会触发的触发器。触发器将调用一个函数,该函数将记录 Google Apps Scripts

上突出显示的单元格的行号

我已经编写了一个函数来执行此操作:

function getCell() {
  var app = SpreadsheetApp;
  var ss = app.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();

  //get the current highlighted cell
  var cell = sheet.getCurrentCell();

  //get the row number
  var row = cell.getRow(); 

  //log the value
  Logger.log(row);

}

但是我不知道触发器怎么写。目前,我每次单击其他单元格时都必须 运行 脚本。

https://developers.google.com/apps-script/guides/triggers/. An alternative that could serve as a workaround is to use the "poll technique" described on

中描述了可用的触发器

奇怪,第一次成功....

function onSelectionChange(e){
   Browser.msgBox('cell selection change');
}

也许问题发布后情况发生了变化,但落在了这里。