I'm playing with Google Sheets since a few days and I'm up to the point when i'm trying to "see" where the user is on the sheet.
To achieve that, i tried using the getActiveCell() method in a while loop, like that :
function menuItem1() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
row = 0;
while(1) //WARNING : infinite loop
{
new_row = sheet.getActiveCell().getRow();
if (row != new_row)
{
Browser.msgBox("You have selected row " + new_row);
row = new_row;
}
}
}
In short, if the user selects a new cell, a message box will prompt, displaying the row of the new cell.
And for some reason, it works only for the first loop iteration. I launch the script, the message box tells me 'You have selected row xxx', and if select a cell in an other row... it does nothing.
When digging through the documentation, I discovered the getCurrentCell() method, but it does exactly the same.
It looks like while the while loop is running, the script can't "see" the updates on the sheet.
What did I do wrong in my code ? Or is it a known (weird) behavior ?
Thanks for any help =)