Context Menu - Insert into a Text Input box

1,320 views
Skip to first unread message

Mark Lunney

unread,
Sep 23, 2010, 11:15:03 AM9/23/10
to Chromium-extensions
Hi,

I'm trying to use the Context Menu API to insert text into input text
boxes from a list in the menu. Example of my code so far:

var pasteItem = chrome.contextMenus.create({"title": title, "contexts":
["editable"], "onclick": onClickPaste});

function onClickPaste(info, tab) {
console.log("info= " + JSON.stringify(info));
}

Log: info = {"editable":true,"menuItemId":2,"pageUrl":"..."}

I can't seem to figure out how to modify the context menu being
clicked though, as no information about the element being clicked is
returned.

As the 'editable' variable is being returned true it seems strange
that there's no way to edit the item. Anyone know a way?

Thanks,
Mark

Antony Sargent

unread,
Sep 23, 2010, 1:52:27 PM9/23/10
to Mark Lunney, Chromium-extensions
The 'editable' flag in the info refers to the type of DOM element in the page where the context menu was activated ; a value of true means it was something like an input, textarea, etc. 


Unfortunately in your case there probably isn't enough information to find the actual input element in the page. We plan to fix this in the future. You can star this bug to get updates:




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


Mark Lunney

unread,
Sep 23, 2010, 3:17:35 PM9/23/10
to Chromium-extensions
Thanks for the reply Antony, I guess I'll have to leave this for now.

I've starred the issue, would certainly open up a lot more extension
possibilities.

On Sep 23, 6:52 pm, Antony Sargent <asarg...@chromium.org> wrote:
> The 'editable' flag in the info refers to the type of DOM element in the
> page where the context menu was activated ; a value of true means it was
> something like an input, textarea, etc.
>
> http://code.google.com/chrome/extensions/contextMenus.html#type-OnCli...
>
> Unfortunately in your case there probably isn't enough information to find
> the actual input element in the page. We plan to fix this in the future. You
> can star this bug to get updates:
>
> http://crbug.com/39507
>
> On Thu, Sep 23, 2010 at 8:15 AM, Mark Lunney <mark.p.lun...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm trying to use the Context Menu API to insert text into input text
> > boxes from a list in the menu. Example of my code so far:
>
> > var pasteItem = chrome.contextMenus.create({"title": title, "contexts":
> > ["editable"], "onclick": onClickPaste});
>
> > function onClickPaste(info, tab) {
> >        console.log("info= " + JSON.stringify(info));
> > }
>
> > Log: info = {"editable":true,"menuItemId":2,"pageUrl":"..."}
>
> > I can't seem to figure out how to modify the context menu being
> > clicked though, as no information about the element being clicked is
> > returned.
>
> > As the 'editable' variable is being returned true it seems strange
> > that there's no way to edit the item. Anyone know a way?
>
> > Thanks,
> > Mark
>
> > --
> > 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>
> > .

he...@frogsbo.com

unread,
Feb 23, 2014, 8:57:19 PM2/23/14
to chromium-...@chromium.org
Hi, I want to code a context menu that writes pre-defined text into textbox:

[code]
>ContextMenuSmileys
      >>Category1 
            >>>HappySmiley1Text
            >>>HappySmiley2Text
      >>Category2 
           >>>ConfusedSmiley1Text
           >>>ConfusedSmiley2Text
[/code]

Is the answer to my quest the same as in this topic? It's my first chrome extension, I would be very grateful if someone could provide me a standard template for this task. 

Thankyou
Reply all
Reply to author
Forward
0 new messages