Update context menu label before visualization

505 views
Skip to first unread message

dafi

unread,
Oct 18, 2010, 2:35:35 AM10/18/10
to Chromium-extensions
I need to update the context menu label before it appears on screen.

Consider the standard context menu 'Search' that shows the initial
part of selection

Search "lorem ipsum..." with Google

I need to create the label based on url and selection

Any hint?

thanks in advance

Mohamed Mansour

unread,
Oct 18, 2010, 9:19:31 AM10/18/10
to dafi, Chromium-extensions
If you need to update the context menu, you can use:
chrome.contextMenus.update(integer idobject updatePropertiesfunction callback)

Mentioned here:

You keep track of your contextMenu id in your background page, and you refer to that id when you request an update for the updateProperties.title.

-
Mohamed Mansour
m...@chromium.org



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


dafi

unread,
Oct 18, 2010, 9:26:07 AM10/18/10
to Chromium-extensions
I know about update but I must update **before** the menu is shown on
screen inspecting the menu target type (image, link, video, audio) so
the question is

Is there an event to listen to update menu item before it appears on
screen?
Firefox has popupshowing/popuphidden to change menu properties before
it is shown


On Oct 18, 3:19 pm, Mohamed Mansour <m0.interact...@gmail.com> wrote:
> If you need to update the context menu, you can use:
> chrome.contextMenus.update(integer id, object updateProperties, function
> callback)
>
> Mentioned here:http://code.google.com/chrome/extensions/contextMenus.html
>
> You keep track of your contextMenu id in your background page, and you refer
> to that id when you request an update for the updateProperties.title.
>
> -
> Mohamed Mansour
> m...@chromium.org
>
> On Mon, Oct 18, 2010 at 2:35 AM, dafi <davide.fic...@gmail.com> wrote:
> > I need to update the context menu label before it appears on screen.
>
> > Consider the standard context menu 'Search' that shows the initial
> > part of selection
>
> > Search "lorem ipsum..." with Google
>
> > I need to create the label based on url and selection
>
> > Any hint?
>
> > thanks in advance
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > .

Mohamed Mansour

unread,
Oct 18, 2010, 10:17:30 AM10/18/10
to dafi, Chromium-extensions
Dafi, did you try doing something like this:

chrome.experimental.contextMenu.create({"title": "Searching '%s'", "onclick": getSearch,
                          "contexts":["SELECTION"]});

The %s is the placeholder.

You can read more about it here:

-
Mohamed Mansour
m...@chromium.org


To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

dafi

unread,
Oct 18, 2010, 10:26:40 AM10/18/10
to Chromium-extensions
Great!! This works fine on selection ;)

Now I need to understand if I can crate my own label and everything
goes ok

thanks again,

dafi

On Oct 18, 4:17 pm, Mohamed Mansour <m...@chromium.org> wrote:
> Dafi, did you try doing something like this:
>
> chrome.experimental.contextMenu.create({"title": "Searching '%s'",
> "onclick": getSearch,
>                           "contexts":["SELECTION"]});
>
> The %s is the placeholder.
>
> You can read more about it here:http://groups.google.com/a/chromium.org/group/chromium-extensions/bro...<http://groups.google.com/a/chromium.org/group/chromium-extensions/bro...>
> <http://groups.google.com/a/chromium.org/group/chromium-extensions/bro...>
> -
> Mohamed Mansour
> m...@chromium.org
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>

PhistucK

unread,
Oct 18, 2010, 2:38:15 PM10/18/10
to Kathy, Chromium-extensions
Can you, please, update this in the documentation (feel free to copyedit ;))?

title 
optional string )
This must be specified unless type is 'separator'.
When the 'selection' context is used, "%s" can be added within the string, in order to show the selected text.
Example - Translate '%s' with the dictionary --> Translate 'cool' with the dictionary.

Thank you.

PhistucK



To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

Kathy Walrath

unread,
Oct 19, 2010, 6:40:10 PM10/19/10
to PhistucK, Chromium-extensions
Sure, I'll do it. That looks like a good change (though of course I
can't stop myself from copyediting :).

-k-

Antony Sargent

unread,
Oct 19, 2010, 7:17:26 PM10/19/10
to Kathy Walrath, PhistucK, Chromium-extensions
Please feel free to improve the rest of the page while you're in there. =)

Dan Atkinson

unread,
Oct 22, 2010, 6:00:25 PM10/22/10
to Chromium-extensions
Is there any way that this can be extended to, say images?

I'm writing an extension which will update one of the sections in the
context menus with the name of the current image.

However, there's no way of doing this when the context menu is shown.

Thanks, Dan

On Oct 18, 3:17 pm, Mohamed Mansour <m...@chromium.org> wrote:
> Dafi, did you try doing something like this:
>
> chrome.experimental.contextMenu.create({"title": "Searching '%s'",
> "onclick": getSearch,
>                           "contexts":["SELECTION"]});
>
> The %s is the placeholder.
>
> You can read more about it here:http://groups.google.com/a/chromium.org/group/chromium-extensions/bro...<http://groups.google.com/a/chromium.org/group/chromium-extensions/bro...>
> <http://groups.google.com/a/chromium.org/group/chromium-extensions/bro...>
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>

Arne Roomann-Kurrik

unread,
Oct 26, 2010, 11:55:21 AM10/26/10
to Dan Atkinson, Chromium-extensions
It's not possible - check crbug.com for an existing request and file one if you don't fine anything.

Out of curiosity, what's the "name" of an image?  Would you just use alt text or the name attribute if available? 

~Arne


To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

Dan Atkinson

unread,
Oct 26, 2010, 12:04:45 PM10/26/10
to Chromium-extensions
Hi Arne,

Thank you for getting back to me. A cursory search for 'contextMenus'
shows nothing related to this issue.

When I say 'name' of the image, I mean the filename. So, for example,
let's say we have the url http://www.example.com/images/myImage3.jpg,
the filename/name will be 'myImage3.jpg'. Sorry for the confusion; I
should have said filename.

I suppose that using the alt text could be acceptable, although the
existence of it shouldn't be relied upon as the image could actually
be in its own tab.

For my purposes though, I only want the image name as it's a feature
I'm trying to add to my extension - ChromeFusk (https://
chrome.google.com/extensions/detail/glieaboaghdnlglpkekghloldikefofo).

Many thanks, Dan
> > > > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>
> > <chromium-extensions%252Bunsubscr...@chromium.org<chromium-extensions%25252Bunsubscr...@chromium.org>

Dan Atkinson

unread,
Oct 26, 2010, 12:39:39 PM10/26/10
to Chromium-extensions
I have raised this as http://code.google.com/p/chromium/issues/detail?id=60758.

Thanks, Dan

On Oct 26, 5:04 pm, Dan Atkinson <d...@dan-atkinson.com> wrote:
> Hi Arne,
>
> Thank you for getting back to me. A cursory search for 'contextMenus'
> shows nothing related to this issue.
>
> When I say 'name' of the image, I mean the filename. So, for example,
> let's say we have the urlhttp://www.example.com/images/myImage3.jpg,

Arne Roomann-Kurrik

unread,
Oct 26, 2010, 12:46:05 PM10/26/10
to Dan Atkinson, Chromium-extensions
Thanks!  Filename makes sense, although it may be easier to get a new substitution pattern put in than the ability to arbitrarily change the text (you wouldn't want extension code slowing down the UI for things like context menus).  We'll see how the issue gets triaged.

~Arne

To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
Reply all
Reply to author
Forward
0 new messages