Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you monitor for click events in Google Apps script for spreadsheets?

I'm managing a Google spreadsheet with a script. onEdit is working - I can colour a cell red by putting

SpreadsheetApp.getActiveRange().setBackgroundRGB(255, 0, 0);

in the onEdit function. I would like to put the same code in a onClick function, so that when a user clicks on a cell it immediately turns red. Is this possible? I can't find any way to do it in the documentation.

like image 986
user1002973 Avatar asked Apr 08 '13 21:04

user1002973


3 Answers

As stated on the comments above before there's no way (right now) to create an onClick() function for Google Spreadsheets. That makes sense due to the fact that the google app script functions are processed in the server, the amount of load generated by onClick() events execution would make pretty easy to deplete all the quota of requests provided by default.

You should be using the documentation for creating a button and clicking on it.

like image 86
Leonardo Avatar answered Oct 09 '22 12:10

Leonardo


You can get closer....Create a validation for the cells with an option...like "Done". Click the dropdown, select Done. now create a trigger onChange or onEdit to fire. You can get a cell/range contextualized function....like firing on a row or column. This is easy to replicate and program for

like image 44
user875479 Avatar answered Oct 09 '22 11:10

user875479


You can add a Drawing as a button - https://developers.google.com/apps-script/guides/menus#clickable_images_and_drawings_in_google_sheets

like image 32
fung Avatar answered Oct 09 '22 12:10

fung