Dynamic context menus on right click

1,307 views
Skip to first unread message

phil swenson

unread,
Mar 3, 2012, 8:01:15 PM3/3/12
to Chromium-extensions
I'm starting to think this simply doesn't work in chrome as it is
quite niche I think.

I am trying to let a user select text and based on the selected text
create a context menu item.

For example:

if the selected text is 303-393-3939 I want a context menu "dial 303-393-3939"

if the selected text is "3032 drury lane colorado springs co 48483" I
want a context menu item "map this location"

I've encountered a major problem.

The code is described here:
http://stackoverflow.com/questions/9550090/chrome-extension-context-menu-not-working
Basically, if I remove the previous context menu items using code like so:

chrome.contextMenus.removeAll(function(){
chrome.contextMenus.create({
"title": "note type = " + notification_type,
"contexts":["selection"],
"onclick": genericOnClick
});
});

then the click event on the context item never fires when selected.

Has anyone done what I'm trying to do? Are there any extensions out
there that do this?

Thanks!
phil

Mohamed Mansour

unread,
Mar 4, 2012, 12:04:28 AM3/4/12
to phil swenson, Chromium-extensions
Hi Phil,

I have answered your question on StackOverflow. Basically, you need the %s in the title.

   "dial %s"

When the context is 'selection', you can use %s within the string to show the selected text.

Kind regards,
Mohamed Mansour



phil

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


phil swenson

unread,
Mar 4, 2012, 1:12:30 PM3/4/12
to Mohamed Mansour, Chromium-extensions
while this is useful, I don't think it helps with my need to change
other text than the selected portion.

For example, if the selected text is a street address, I don't want a
"dial" option in the context menu. I want it to be "map this
location" in the context menu.

Or am I missing something?

Thanks for your reply.
phil

Reply all
Reply to author
Forward
0 new messages