Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 3 of 3

This is a discussion on Context menu for editable items within the Plugins Development section, part of the Chrome Plugins category: Hi everyone, I am developing a small extension that adds a context menu to "editable" items on pages. This works ...


  1. #1
    devnull69 is offline Member
    Join Date
    Jul 2010
    Posts
    32

    Default Context menu for editable items

    Hi everyone,

    I am developing a small extension that adds a context menu to "editable" items on pages. This works quite well. But after hours of intense research I was not able to find out which page element the context menu had been activated from.

    Example: There are text boxes on a page. When I right click on one of the text boxes I get my context menu. In the "onclick" callback of the context menu I want to detect which text box I clicked on ... how can I do that?

    Thomas

  2. #2
    devnull69 is offline Member
    Join Date
    Jul 2010
    Posts
    32

    Default

    Never mind, I found out

    You can use an event listener for "contextmenu" to determine the element in a content script:
    Code:
    window.addEventListener('contextmenu', function(event) {
       myelement = event.target;
    }, false);

  3. #3
    PAEz's Avatar
    PAEz is offline Moderator
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    656

    Default

    Thanks for coming back and sharing that with us, great workaround for the problem, works great.

Similar Threads

  1. Replies: 3
    Last Post: 08-12-2011, 11:35 AM
  2. Adding item to context menu on right-click on link
    By afin in forum Plugins Development
    Replies: 5
    Last Post: 11-20-2010, 05:05 AM
  3. parent and child context menu o selection?
    By d3st in forum Plugins Development
    Replies: 0
    Last Post: 10-06-2010, 06:19 PM
  4. change double click context menu to single click.
    By bmorency in forum Chrome Troubleshooting
    Replies: 0
    Last Post: 07-25-2010, 01:08 AM
  5. Suppressing right-click context menu
    By Hemmer in forum Plugins Development
    Replies: 7
    Last Post: 02-14-2010, 11:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •