PERGOLA LOGO

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.

pergola.contextmenuManager

pergola.contextmenuManager.browser(evt)

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).

pergola.contextmenuManager.custom(evt)

Handler for "mousedown" event registered on the window object by custom context menu open() method; checks if a custom context menu is open (pergola.ContextMenu.active) 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 evt.target with callback handler. On mouseup: assigns a pergola.ContextMenu instance to the evt.target.contextmenu 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.