Jody Heavener
Jody Heavener

Reputation: 2864

Roll own context menu but maintain system items?

I'm using jQuery to create my own right-click context menu, but I'd like to maintain the system items such as Copy, Paste, Inspect Element, etc.

I know I can roll my own copy/paste functions, but how would I go about triggering the Dom Inspector/Inspect Element tool?

Any help is appreciated.

Upvotes: 1

Views: 135

Answers (1)

dan
dan

Reputation: 2388

This is not possible with JavaScript.

You have two options that I can think of.

  1. Don't use custom context menus

  2. Allow the user to get back original functionality if they wish. For example by showing the original context menu if the shift key is pressed. Some browsers (Firefox) do this for you

:

$(document).on('contextmenu', function(event) {
    if(event.shiftKey || event.ctrlKey) {
        return;
    }

    event.preventDefault();

    // Position and show my custom context menu element.
});

Upvotes: 0

Related Questions