Context Menu Manager

Allows to replace the browser's context menu for any element. Learn more in the Custom Context Menu section of the Tutorial.



Handler for "contextmenu" event registered on the window object; prevents the browsers's context menu if pergola.contextmenuEnabled is false, then resets it to true (the initial state).


Handler for "mousedown" event registered on the window object by custom context menu open() method; checks if a custom context menu is open ( and invokes its close() method, where the "mousedown" event registered on the window object gets removed.

pergola.contextmenuManager.activate(evt, callback, items)

On mousedown: adds mouseup event listener to with callback handler. On mouseup: assigns a pergola.ContextMenu instance to the property; sets pergola.contextmenuEnabled to false to prevent the browser's context menu; removes the mouseup event listener; invokes custom context menu open() method.

Invoke this function from right mouse button test in element's/object's event handler. Learn more in the CUSTOM CONTEXT MENU section of the Tutorial.