useContextMenuHandlers
useContextMenuHandlers<
TData>():object
Defined in: contextMenu.tsx:492
Hook to get context menu handlers for table cells and column headers.
This hook provides event handlers that:
- Prevent default browser context menu
- Calculate element position (DOMRect)
- Open the appropriate context menu type
Type Parameters
Section titled “Type Parameters”TData
Returns
Section titled “Returns”Object with handleCellContextMenu and handleColumnContextMenu functions
handleCellContextMenu()
Section titled “handleCellContextMenu()”handleCellContextMenu: (
e,cell,column,row) =>void
Handler for cell context menu events. Call this in the onContextMenu prop of table cells.
Parameters
Section titled “Parameters”MouseEvent<HTMLTableCellElement>
Cell<TData, unknown>
column
Section titled “column”Column<TData, unknown>
Row<TData>
Returns
Section titled “Returns”void
handleColumnContextMenu()
Section titled “handleColumnContextMenu()”handleColumnContextMenu: (
e,column) =>void
Handler for column header context menu events. Call this in the onContextMenu prop of table header cells.
Parameters
Section titled “Parameters”MouseEvent<HTMLTableCellElement>
column
Section titled “column”Column<TData, unknown>
Returns
Section titled “Returns”void
Example
Section titled “Example”const handlers = useContextMenuHandlers<Person>();
<td onContextMenu={(e) => handlers.handleCellContextMenu(e, cell, column, row)}> {content}</td>
<th onContextMenu={(e) => handlers.handleColumnContextMenu(e, column)}> {header}</th>