Skip to content

Commit 6ebd14e

Browse files
committed
Added new sample for upcoming onSelectionChange trigger.
Change-Id: I2ef4e3cf6c2b8ed7602259d2990e493cbd447a8c
1 parent f98fef3 commit 6ebd14e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

triggers/triggers.gs

+17
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ function onEdit(e) {
2424
}
2525
// [END apps_script_triggers_onedit]
2626

27+
// [START apps_script_triggers_onselectionchange]
28+
/**
29+
* The event handler triggered when the selection changes in the spreadsheet.
30+
* @param {Event} e The onSelectionChange event.
31+
*/
32+
function onSelectionChange(e) {
33+
// Set background to red if a single empty cell is selected.
34+
var range = e.range;
35+
if(range.getNumRows() == 1
36+
&& range.getNumColumns() == 1
37+
&& range.getCell(1, 1).getValue() == "") {
38+
range.setBackground("red");
39+
}
40+
}
41+
// [END apps_script_triggers_onselectionchange]
42+
43+
2744
// [START apps_script_triggers_oninstall]
2845
/**
2946
* The event handler triggered when installing the add-on.

0 commit comments

Comments
 (0)