I\'m managing a Google spreadsheet with a script. onEdit is working - I can colour a cell red by putting
SpreadsheetApp.getActiveRange().setBackgroundRGB(25
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
Create a "Drawing" with background transparent; then move and place the drawing on top of the cell you need and then assign the script to the drawing.
I believe the new trigger onSelectionChange(e) will achieve this. It's in the docs but at time of writing isn't yet working on my sheet. https://developers.google.com/apps-script/guides/triggers?hl=en
Try this for a click event:
function onSelectionChange(e) {
e.source.toast('Sheet: ' + e.range.getSheet()(.getName() + ' Range: ' + e.range.getA1Notation());
}
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.
You can add a Drawing as a button - https://developers.google.com/apps-script/guides/menus#clickable_images_and_drawings_in_google_sheets