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)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1070952

People

(Reporter: canuckistani, Unassigned)

References

Details

(Whiteboard: [jpcontextmenu])

Attachments

(1 file)

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]
Depends on: 788324
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.
(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.
Assignee: nobody → dtownsend+bugmail
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.
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
Assignee: dtownsend+bugmail → nobody
With this patch, we can do something like this: const { Item } = require("sdk/context-menu"); const item = Item({ ... }); item.on("click", function(context) { ... });
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.

Attachment

General

Created:
Updated:
Size: