Modifying the context menus of firebug

96 views
Skip to first unread message

Mifham Siddeek

unread,
Apr 8, 2012, 6:40:23 PM4/8/12
to Firebug
I want to modify the context menu of firebug with additional options
such as saving the highlighted code...please let me know how I can add
more options to the right click menu (context menu)..

Jan Honza Odvarko

unread,
Apr 10, 2012, 3:23:52 AM4/10/12
to Firebug
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
Message has been deleted

Jan Honza Odvarko

unread,
Mar 3, 2014, 2:00:14 PM3/3/14
to fir...@googlegroups.com
Just for the record, Firebug extension example showing how to extend the context menu is available here:

https://github.com/firebug/extension-examples/tree/master/ContextMenu

Honza

Reply all
Reply to author
Forward
0 new messages