Submenus in extensions (toolbars) - Mozilla

This is a discussion on Submenus in extensions (toolbars) - Mozilla ; Can someone point me to a snippet that constructs a submenu of a menu for a toolbar extension. I've been busy crashing my browser all this morning trying to get what should be a simple task done. This is as ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Submenus in extensions (toolbars)

  1. Submenus in extensions (toolbars)

    Can someone point me to a snippet that constructs a submenu of a menu
    for a toolbar extension. I've been busy crashing my browser all this
    morning
    trying to get what should be a simple task done.

    This is as close as I have come (it has a submenu, but selecting it
    crashes the browser)

    const XULNS = 'http://www.mozilla.org/keymaster/gatekeeper/
    there.is.only.xul';

    function populateEventsMenu(event){
    try {
    var menu = document.getElementById('btn_popup');
    removeAllChildren(menu);
    for(var j = 0; j < 5; j++){
    if(j != 3){
    menu.appendChild(createMenuItem("Tab #" + j, j, dummy));
    } else {
    var submenu = document.createElementNS(XULNS, "menu");
    var submenupopup = document.createElementNS(XULNS,
    "menupopup");
    submenu.setAttribute("label", "Tab #" + j);
    submenu.appendChild(submenupopup);
    var first = createMenuItem("First item", 7, dummy);
    var last = createMenuItem("Last item", 8, dummy);
    submenupopup.appendChild(last);
    menu.appendChild(submenu);
    }
    }
    } catch(err){

    }
    }



    function createMenuItem(label, value, listener){
    var item = document.createElementNS(XULNS, "menuitem");
    item.setAttribute("label", label);
    item.setAttribute("class", "menuitem-iconic");
    item.addEventListener('command', listener, true);
    item.setAttribute("value", value);
    return item;
    }

    function dummy(event){ }

  2. Re: Submenus in extensions (toolbars)

    On Apr 8, 12:21 pm, "Ian A. Mason"
    wrote:
    > Can someone point me to a snippet that constructs a submenu of a menu
    > for a toolbar extension. I've been busy crashing my browser all this
    > morning
    > trying to get what should be a simple task done.
    >
    > This is as close as I have come (it has a submenu, but selecting it
    > crashes the browser)


    Since no one else has replied with anything definitively helpful, I
    can offer only some mild assurance:

    The structure of what you are doing matches my understanding of how to
    to piece together menu/menupopup/menuitem elements (see a known
    working structure below). The bug must lie somewhere in the guts of
    the rest of your app-specific logic.


    ....

    oncommand="SHPI_markAsImage(event);"/>

    oncommand="SHPI_clearAllMarks(event);"/>


    ...


  3. Re: Submenus in extensions (toolbars)

    Alas Tony I wish I were so lucky. No it is definitely
    caused by the dynamic construction of the
    sumenu. I have an extension that does nothing but
    make one button dropdown with the dreaded nesting.
    Crashes my (2.*) browser (on Linux) every time without
    fail (selecting the submenu). On windows it doesn't
    crash the browser, but does make it sick enough
    that I have to kill it from the task manager, even 3b5.


    On Apr 9, 5:44 pm, arc wrote:
    > On Apr 8, 12:21 pm, "Ian A. Mason"
    > wrote:
    >
    > > Can someone point me to a snippet that constructs a submenu of a menu
    > > for a toolbar extension. I've been busy crashing my browser all this
    > > morning
    > > trying to get what should be a simple task done.

    >
    > > This is as close as I have come (it has a submenu, but selecting it
    > > crashes the browser)

    >
    > Since no one else has replied with anything definitively helpful, I
    > can offer only some mild assurance:
    >
    > The structure of what you are doing matches my understanding of how to
    > to piece together menu/menupopup/menuitem elements (see a known
    > working structure below). The bug must lie somewhere in the guts of
    > the rest of your app-specific logic.
    >
    >

    > ....
    > >
    > > oncommand="SHPI_markAsImage(event);"/>
    >
    > > oncommand="SHPI_clearAllMarks(event);"/>
    >

    >

    > ...
    >





+ Reply to Thread