Skip to content
SumOfficeSumOfficeSumOffice

Responding to clicks and the context menu

How to handle a click on the sheet, selection, and your own context menu.

The operations contract is responsible for the workbook’s meaning; your interface is responsible for pointer events. Keep these responsibilities separate:

Event or task Who’s responsible What to pass
Click and double-click Your interface The coordinate, what was hit, the current selection
Context menu Your interface The object type and the commands allowed for it
A cell’s value or formula The core sheetKey, row, col, inputKind, input
Undo and redo The core subsetId and the direction
Save The core subsetId and the destination address

What the interface passes along with a click

Section titled “What the interface passes along with a click”
{
"subsetId": "subset-...",
"sheetKey": "xl/worksheets/sheet1.xml",
"selection": { "top": 0, "left": 0, "rows": 1, "cols": 1 },
"hit": { "kind": "cell", "row": 0, "col": 0 },
"pointer": { "kind": "double-click", "button": 0 }
}

This is your own shape, not a request to the core. The hit and pointer fields don’t exist in the contract at all, and selection is there, but means something else: a string like A1:B4, not an object with area bounds. You can’t copy this block straight into a request — what goes to the core is the cell address and the value type.

The interface uses an object like this to decide which menu to show. A command that changes the workbook then turns into a strictly typed request to the core. Don’t send the core markup nodes or chunks of HTML: it works with cell addresses and value types, not with what’s drawn on screen.

Documentation assistant

Answers are assembled from the documentation and may be inaccurate — check the sources.