See an example:
(based on
https://github.com/janodvarko/httpmonitor/blob/master/content/net/jsonViewer.js#L60)
var myModule = Obj.extend(Firebug.Module,
{
initialize: function()
{
Firebug.Module.initialize.apply(this, arguments);
Firebug.registerUIListener(this);
},
shutdown: function()
{
Firebug.Module.shutdown.apply(this, arguments);
Firebug.unregisterUIListener(this);
},
onContextMenu: function(items, object, target, context, panel,
popup)
{
// Check panel name, your menu item doesn't have to be
available
// in every panel
if (
panel.name != "net" &&
panel.name != "console")
return;
// You can use clicked element
var memberLabel = Dom.getAncestorByClass(target,
"memberLabel");
if (!memberLabel)
return;
var row = Dom.getAncestorByClass(target, "memberRow");
if (!row || !row.domObject.value)
return;
// Append a new menu item
items.push({
id: "fbNetCopyJSON",
nol10n: true,
label: Locale.$STRF("net.jsonviewer.Copy_JSON",
[
row.domObject.name]),
command: Obj.bindFixed(this.copyJsonResponse, this, row)
});
},
});
* Register a new UI listener - Firebug.registerUIListener
* Make sure the listener is also unregistered
* Implement 'onContextMenu' methods that will be called by the
framework automatically when the user right click in a Firebug panel
* Passed parameters:
- items: array with existing menu items
- clicked object
- target element
- current Firebug context
- the current panel object
- the popup menu itself
Honza