ImFusion Web SDK

useContextMenu

ts
function useContextMenu(callback: (menu: Menu, event: Event) => void): void;

Registers a context menu handler that fires when the SDK produces a context menu from an input event.

Parameters

ParameterTypeDescription
callback(menu: Menu, event: Event) => voidReceives the Menu and the DOM Event that triggered it

Returns

void

Throws

If called outside of an ImFusionProvider

Throws

If called before the SDK has finished initializing

Example

tsx
function ContextMenuHandler() {
  useContextMenu((menu, event) => {
    event.preventDefault();
    // Build a custom menu UI from menu.items()
  });
  return null;
}