Closed
Bug 773914
Opened 12 years ago
Closed 10 years ago
ENH Implement an onClick handler for context-menu
Categories
(Add-on SDK Graveyard :: General, defect, P2)
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 1070952
People
(Reporter: canuckistani, Unassigned)
References
Details
(Whiteboard: [jpcontextmenu])
Attachments
(1 file)
1.26 KB,
patch
|
Details | Diff | Splinter Review |
An idea to improve the usability of the context-menu module is to generically handle this pattern:
var item = cm.Item({
label: "Label!",
image: data.url('favicon.png'),
context: cm.SelectorContext('a[href $=".zip"]'),
contentScript: 'self.on("click", function (node, data) {' +
' self.postMessage(node.href);' +
'});',
...
}):
We should instead be able to do something like:
var item = cm.Item({
label: "Label!",
image: data.url('favicon.png'),
context: cm.SelectorContext('a[href $=".zip"]'),
onClick: function(context) {},
...
}):
In the above case, 'context' would be an appropriate set of data derived from the target node that the callback could react to, eg element properties.
Priority: -- → P3
Whiteboard: [jpcontextmenu]
Comment 1•12 years ago
|
||
We can't pass the context node to the onClick handler since that would violate chrome/content separation so I'm not sure how useful this would be.
Comment 2•12 years ago
|
||
(In reply to Dave Townsend (:Mossop) from comment #1)
> We can't pass the context node to the onClick handler since that would
> violate chrome/content separation so I'm not sure how useful this would be.
I think Jeff meant that onClick would be passed JSON with the node's attributes. Besides the attributes, we could pass values like 'tagName' string and 'childNodes' array.
I think this would be handy as well.
Priority: P3 → P2
Assignee: nobody → dtownsend+bugmail
Comment 3•12 years ago
|
||
I think we should start with a data equivalent to chrome:
http://developer.chrome.com/extensions/contextMenus.html
As of passing back attributes, nodeNames etc.. Have we had any specific use cases yet ? I feel attributes and tag names are not worth passing as users define contexts using CSS selectors that can specify attributes. Maybe that's not enough but I would prefer to defer adding more data until we do actually have valid uses cases. Once we have we can decide what the best data to pass is.
Comment 4•12 years ago
|
||
Although chrome API does not seems to have associated tab.id which seems like something we should add to support use cases outlined in Bug 824348
Updated•11 years ago
|
Assignee: dtownsend+bugmail → nobody
Comment 5•11 years ago
|
||
With this patch, we can do something like this:
const { Item } = require("sdk/context-menu");
const item = Item({
...
});
item.on("click", function(context) {
...
});
Blocks: 982575
Comment 6•10 years ago
|
||
The context-menu@2 api handles this use case.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•