I have a Firefox extension that adds several buttons to the “nav-bar” toolbar using recommended technique (see https://developer.mozilla.org/en/Code_snippets/Toolbar#Adding_button_by_default). Everything works fine, buttons are added on first start, users are able to add, remove or reorganise the buttons.
I need to be able to add and remove these buttons via custom dialog. And here’s the problem: I can add buttons via insertItem method, but there is no removeItem method.
I can remove the item by calling removeChild DOM method and then removing the item ID from toolbar’s currentset attribute. But then I can’t reenable the item before restarting the browser, because it doesn’t return to the palette.
// remove item's ID from toolbar's current set of items
// this does not remove the item
toolbar.setAttribute('currentset', newSet);
document.persist(toolbar.id, 'currentset');
// item is removed, but it doesn't return to palette
// so it can't be added againg before restart
toolbar.removeChild(button);
Is there any way I can not only add, but also remove items from Firefox toolbars programatically? Thanks.
What happens if you just update the
"currentSet"property and don’t callremoveChild? That should move the button to the palette I think.