Sorry, replying to the entire group. I logged this bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=836318
Dave updated the bug with an explanation on how the
feature has changed:
"This is caused by two changes that were made to the behaviour of the
context-menu module.
First items that are children of menus still support the context
property and without one they default to the PageContext. So when
context clicking on a link the Google and Wikipedia items get hidden.
Second if a menu contains no visible item it gets hidden, so the menu
gets hidden in this example."
I updated my example to now work with 1.13:
var cm = require("sdk/context-menu");
var googleItem = cm.Item({
label: "Google",
context: cm.SelectorContext("a[href]"),
data: "
http://www.google.com/search?q="
});
var wikipediaItem = cm.Item({
label: "Wikipedia",
context: cm.SelectorContext("a[href]"),
data: "
http://en.wikipedia.org/wiki/Special:Search?search="
});
var searchMenu = cm.Menu({
label: "Search With",
context: cm.SelectorContext("a[href]"),
contentScript: 'self.on("click", function (node, data) {' +
' var searchURL = data + node.textContent;' +
' window.location.href = searchURL;' +
'});',
items: [googleItem, wikipediaItem]
});
cheers, Jeff
On Wed, Jan 30, 2013 at 2:06 AM, <
izydor....@gmail.com> wrote:
> There seems to be a problem with the context-menu module. The .Menu
> constructor is ignoring the context option - even when I set the context to
> .PageContext(). When I create a top-level menu with two items and set its
> context, the menu doesn't show up at all. However, when I put both items on
> the top-level, without the menu, the context set on them individually works
> ok for them. I thought maybe it's something with my code, but this example
> from the documentation doesn't work either:
>
> var cm = require("sdk/context-menu");
> var googleItem = cm.Item({
> label: "Google",
> data: "
http://www.google.com/search?q="
> });
> var wikipediaItem = cm.Item({
> label: "Wikipedia",
> data: "
http://en.wikipedia.org/wiki/Special:Search?search="
> });
> var searchMenu = cm.Menu({
> label: "Search With",
> context: cm.SelectorContext("a[href]"),
> contentScript: 'self.on("click", function (node, data) {' +
> ' var searchURL = data + node.textContent;' +
> ' window.location.href = searchURL;' +
> '});',
> items: [googleItem, wikipediaItem]
> });
>
> The same code compiled with Addon SDK 1.12 works fine.
>
> Cheers, Izek